diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-10 21:29:24 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-10 21:29:24 +0200 |
| commit | aa8bbbbe06646d9264d7780d9962ae4e9038ac40 (patch) | |
| tree | 584a5849c523992f8a8dc48fbbffa1e6d1865aeb | |
| parent | 457ce33d1ca3a23388b93dbfb4cb5dd429a6c0de (diff) | |
| download | vis-aa8bbbbe06646d9264d7780d9962ae4e9038ac40.tar.gz vis-aa8bbbbe06646d9264d7780d9962ae4e9038ac40.tar.xz | |
Add normal mode command 'J'
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | vis.c | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 7a0385c..edf34ca 100644 --- a/config.def.h +++ b/config.def.h @@ -343,6 +343,7 @@ static KeyBinding vis_normal[] = { { { NONE('N') }, movement, { .i = MOVE_SEARCH_BACKWARD } }, { { NONE('o') }, openline, { .i = MOVE_LINE_NEXT } }, { { NONE('O') }, openline, { .i = MOVE_LINE_PREV } }, + { { NONE('J') }, joinline, { .i = MOVE_LINE_NEXT } }, { { NONE('x') }, call, { .f = editor_delete_key } }, { { NONE('r') }, replace, { NULL } }, { { NONE('i') }, switchmode, { .i = VIS_MODE_INSERT } }, @@ -315,6 +315,8 @@ static void insert_tab(const Arg *arg); 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); +/* join the line where the cursor currently is with the one above or below */ +static void joinline(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 */ @@ -705,6 +707,21 @@ static void openline(const Arg *arg) { insert_newline(NULL); } +static void joinline(const Arg *arg) { + Text *txt = vis->win->text; + size_t pos = window_cursor_get(vis->win->win), start, end; + if (arg->i == MOVE_LINE_NEXT) { + start = text_line_end(txt, pos); + end = text_line_next(txt, pos); + } else { + end = text_line_begin(txt, pos); + start = text_line_prev(txt, pos); + } + editor_delete(vis, start, end - start); + editor_insert(vis, start, " ", 1); + window_cursor_to(vis->win->win, start); +} + static void switchmode(const Arg *arg) { switchmode_to(&vis_modes[arg->i]); } |
