vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 8740b5edf2d627e92dc336800a6fbd259ee26992 parent ee9219c0b20e0f4b49b5fe7627f7d8e992db4e8d Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 10 Sep 2014 21:02:28 +0200 Add normal mode commands 'O' and 'o' Diffstat:
| M | config.def.h | | | 2 | ++ |
| M | vis.c | | | 8 | ++++++++ |
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/config.def.h b/config.def.h @@ -341,6 +341,8 @@ static KeyBinding vis_normal[] = { { { NONE('.') }, repeat, { } }, { { NONE('n') }, movement, { .i = MOVE_SEARCH_FORWARD } }, { { NONE('N') }, movement, { .i = MOVE_SEARCH_BACKWARD } }, + { { NONE('o') }, openline, { .i = MOVE_LINE_NEXT } }, + { { NONE('O') }, openline, { .i = MOVE_LINE_PREV } }, { { NONE('x') }, call, { .f = editor_delete_key } }, { { NONE('r') }, replace, { NULL } }, { { NONE('i') }, switchmode, { .i = VIS_MODE_INSERT } }, diff --git a/vis.c b/vis.c @@ -313,6 +313,8 @@ static void insert(const Arg *arg); static void insert_tab(const Arg *arg); /* inserts a newline (either \n or \n\r depending on file type) */ static void insert_newline(const Arg *arg); +/* add a new line either before or after the one where the cursor currently is */ +static void openline(const Arg *arg); /* split current window horizontally (default) or vertically (if arg->b is set) */ static void split(const Arg *arg); /* perform last action i.e. action_prev again */ @@ -697,6 +699,12 @@ static void insert_newline(const Arg *arg) { insert(&(const Arg){ .s = "\n" }); } +static void openline(const Arg *arg) { + movement(&(const Arg){ .i = arg->i == MOVE_LINE_NEXT ? + MOVE_LINE_END : MOVE_LINE_PREV }); + insert_newline(NULL); +} + static void switchmode(const Arg *arg) { switchmode_to(&vis_modes[arg->i]); }