aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-11-02 14:03:26 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-11-02 16:10:29 +0100
commitc3cb6cae3c9d4fb625d5653715ce3323fe3aa1e5 (patch)
treeb9fa0a7f8b7ecab706bb893d7f3013632ec1c7e8 /main.c
parent3840fe853ae3d904d05b583266827786923d8f9b (diff)
downloadvis-c3cb6cae3c9d4fb625d5653715ce3323fe3aa1e5.tar.gz
vis-c3cb6cae3c9d4fb625d5653715ce3323fe3aa1e5.tar.xz
vis: make append (a and A) commands repeatable
Diffstat (limited to 'main.c')
-rw-r--r--main.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/main.c b/main.c
index 722e3dd..3a28e75 100644
--- a/main.c
+++ b/main.c
@@ -24,6 +24,8 @@ static const char *macro_replay(Vis*, const char *keys, const Arg *arg);
static const char *suspend(Vis*, const char *keys, const Arg *arg);
/* switch to mode indicated by arg->i */
static const char *switchmode(Vis*, const char *keys, const Arg *arg);
+/* switch to insert mode after performing movement indicated by arg->i */
+static const char *insertmode(Vis*, const char *keys, const Arg *arg);
/* set mark indicated by keys to current cursor position */
static const char *mark_set(Vis*, const char *keys, const Arg *arg);
/* add a new line either before or after the one where the cursor currently is */
@@ -198,6 +200,8 @@ enum {
VIS_ACTION_INSERT_REGISTER,
VIS_ACTION_WINDOW_NEXT,
VIS_ACTION_WINDOW_PREV,
+ VIS_ACTION_APPEND_CHAR_NEXT,
+ VIS_ACTION_APPEND_LINE_END,
VIS_ACTION_OPEN_LINE_ABOVE,
VIS_ACTION_OPEN_LINE_BELOW,
VIS_ACTION_JOIN_LINE_BELOW,
@@ -730,6 +734,16 @@ static KeyAction vis_action[] = {
"Focus previous window",
call, { .f = vis_window_prev }
},
+ [VIS_ACTION_APPEND_CHAR_NEXT] = {
+ "append-char-next",
+ "Append text after the cursor",
+ insertmode, { .i = MOVE_CHAR_NEXT }
+ },
+ [VIS_ACTION_APPEND_LINE_END] = {
+ "append-line-end",
+ "Append text after the end of the line",
+ insertmode, { .i = MOVE_LINE_END },
+ },
[VIS_ACTION_OPEN_LINE_ABOVE] = {
"open-line-above",
"Begin a new line above the cursor",
@@ -1519,6 +1533,12 @@ static const char *switchmode(Vis *vis, const char *keys, const Arg *arg) {
return keys;
}
+static const char *insertmode(Vis *vis, const char *keys, const Arg *arg) {
+ vis_operator(vis, OP_INSERT);
+ vis_motion(vis, arg->i);
+ return keys;
+}
+
static Vis *vis;
static KeyBinding *default_bindings[] = {