vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 30a20f6a8e33aa9151dd8bc2b26f98fccacc2df2 parent 2fd0feb4f8cea23802560b8c6c8d9f616b9f6e11 Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 4 May 2016 09:34:50 +0200 vis: make j and k a linewise inclusive motion They behave like an inclusive motion, but only if they are also linewise (which they are by default). This should make `yjp` and `ykp` yank both the current and the next/previous line when the cursor is at the start of a line. See also 24091cdb974ff107b3e5b981c4074cbca07c22c2 and #237 Diffstat:
| M | vis-core.h | | | 5 | +++-- |
| M | vis-motions.c | | | 4 | ++-- |
| M | vis.c | | | 3 | ++- |
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/vis-core.h b/vis-core.h @@ -65,8 +65,9 @@ typedef struct { /* Motion implementation, takes a cursor postion and returns a LINEWISE = VIS_MOTIONTYPE_LINEWISE, /* should the covered range be extended to whole lines? */ CHARWISE = VIS_MOTIONTYPE_CHARWISE, /* scrolls window content until position is visible */ INCLUSIVE = 1 << 2, /* should new position be included in operator range? */ - IDEMPOTENT = 1 << 3, /* does the returned postion remain the same if called multiple times? */ - JUMP = 1 << 4, + LINEWISE_INCLUSIVE = 1 << 3, /* inclusive, but only if motion is linewise? */ + IDEMPOTENT = 1 << 4, /* does the returned postion remain the same if called multiple times? */ + JUMP = 1 << 5, /* should the resulting position of the motion be recorded in the jump list? */ } type; void *data; } Movement; diff --git a/vis-motions.c b/vis-motions.c @@ -330,8 +330,8 @@ err: } const Movement vis_motions[] = { - [VIS_MOVE_LINE_UP] = { .cur = view_line_up, .type = LINEWISE }, - [VIS_MOVE_LINE_DOWN] = { .cur = view_line_down, .type = LINEWISE|INCLUSIVE }, + [VIS_MOVE_LINE_UP] = { .cur = view_line_up, .type = LINEWISE|LINEWISE_INCLUSIVE }, + [VIS_MOVE_LINE_DOWN] = { .cur = view_line_down, .type = LINEWISE|LINEWISE_INCLUSIVE }, [VIS_MOVE_SCREEN_LINE_UP] = { .cur = view_screenline_up, }, [VIS_MOVE_SCREEN_LINE_DOWN] = { .cur = view_screenline_down, }, [VIS_MOVE_SCREEN_LINE_BEGIN] = { .cur = view_screenline_begin, .type = CHARWISE }, diff --git a/vis.c b/vis.c @@ -542,7 +542,8 @@ void action_do(Vis *vis, Action *a) { window_jumplist_add(win, pos); else window_jumplist_invalidate(win); - } else if (a->movement->type & INCLUSIVE) { + } else if (a->movement->type & INCLUSIVE || + (linewise && a->movement->type & LINEWISE_INCLUSIVE)) { c.range.end = text_char_next(txt, c.range.end); } } else if (a->textobj) {