diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-10 18:01:05 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-10 18:01:05 +0200 |
| commit | 5fbe797b8aa50c434634da30bad1ad67f2ef98fb (patch) | |
| tree | a6b7bf69d7a4b13a6ba6bb922a6e3e8e9a441493 | |
| parent | 0d448b0d2802a044a77f5546ecd98efb5045adca (diff) | |
| download | vis-5fbe797b8aa50c434634da30bad1ad67f2ef98fb.tar.gz vis-5fbe797b8aa50c434634da30bad1ad67f2ef98fb.tar.xz | |
Add normal mode key binding for 'r'
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | vis.c | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 57e076d..c704b2d 100644 --- a/config.def.h +++ b/config.def.h @@ -336,6 +336,7 @@ static KeyBinding vis_normal[] = { { { NONE('n') }, movement, { .i = MOVE_SEARCH_FORWARD } }, { { NONE('N') }, movement, { .i = MOVE_SEARCH_BACKWARD } }, { { NONE('x') }, call, { .f = editor_delete_key } }, + { { NONE('r') }, replace, { NULL } }, { { NONE('i') }, switchmode, { .i = VIS_MODE_INSERT } }, { { NONE('v') }, switchmode, { .i = VIS_MODE_VISUAL } }, { { NONE('R') }, switchmode, { .i = VIS_MODE_REPLACE} }, @@ -313,6 +313,8 @@ static void insert_newline(const Arg *arg); static void split(const Arg *arg); /* perform last action i.e. action_prev again */ static void repeat(const Arg *arg); +/* replace character at cursor with one read form keyboard */ +static void replace(const Arg *arg); /* adjust action.count by arg->i */ static void count(const Arg *arg); /* force operator to linewise (if arg->b is set) */ @@ -483,6 +485,13 @@ static void repeat(const Arg *arg) { action_do(&action); } +static void replace(const Arg *arg) { + Key k = getkey(); + if (!k.str[0]) + return; + editor_replace_key(vis, k.str, strlen(k.str)); +} + static void count(const Arg *arg) { action.count = action.count * 10 + arg->i; } |
