From b9e8d20523a7bf05e02468efd97bbcf90f18a1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 20 Jan 2016 12:56:38 +0100 Subject: vis: make in insert/replace mode move to the end of line The behaviour of vs $ in various modes may still be inconsistent, but at least it can now be configured via key bindings. --- config.def.h | 3 ++- main.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index a395bcf..30e17bb 100644 --- a/config.def.h +++ b/config.def.h @@ -38,7 +38,7 @@ static const KeyBinding bindings_motions[] = { { "g", ALIAS("gj") }, { "^", ACTION(CURSOR_LINE_START) }, { "g_", ACTION(CURSOR_LINE_FINISH) }, - { "$", ACTION(CURSOR_LINE_END) }, + { "$", ACTION(CURSOR_LINE_LASTCHAR) }, { "%", ACTION(CURSOR_BRACKET_MATCH) }, { "b", ACTION(CURSOR_WORD_START_PREV) }, { "B", ACTION(CURSOR_LONGWORD_START_PREV) }, @@ -232,6 +232,7 @@ static const KeyBinding bindings_normal[] = { { "gp", ACTION(PUT_AFTER_END) }, { "gP", ACTION(PUT_BEFORE_END) }, { "~", ALIAS("l") }, + { "", ALIAS("$") }, { 0 /* empty last element, array terminator */ }, }; diff --git a/main.c b/main.c index 7cb7350..8384ff6 100644 --- a/main.c +++ b/main.c @@ -126,6 +126,7 @@ enum { VIS_ACTION_CURSOR_LINE_FINISH, VIS_ACTION_CURSOR_LINE_BEGIN, VIS_ACTION_CURSOR_LINE_END, + VIS_ACTION_CURSOR_LINE_LASTCHAR, VIS_ACTION_CURSOR_SCREEN_LINE_UP, VIS_ACTION_CURSOR_SCREEN_LINE_DOWN, VIS_ACTION_CURSOR_SCREEN_LINE_BEGIN, @@ -352,6 +353,11 @@ static KeyAction vis_action[] = { [VIS_ACTION_CURSOR_LINE_END] = { "cursor-line-end", "Move cursor to end of the line", + movement, { .i = VIS_MOVE_LINE_END } + }, + [VIS_ACTION_CURSOR_LINE_LASTCHAR] = { + "cursor-line-lastchar", + "Move cursor to last character of the line", movement, { .i = VIS_MOVE_LINE_LASTCHAR } }, [VIS_ACTION_CURSOR_SCREEN_LINE_UP] = { -- cgit v1.2.3