aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-05-04 09:34:50 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-05-04 13:42:05 +0200
commitb9d70d03550b33b40212c98251733e11a6b33ce5 (patch)
treebd81f0f3c502665bb722fbbd52f31c214a92f506
parent68a25c751c0219ef5df589a19513e46a08965d5a (diff)
downloadvis-b9d70d03550b33b40212c98251733e11a6b33ce5.tar.gz
vis-b9d70d03550b33b40212c98251733e11a6b33ce5.tar.xz
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 532f52e9e52b98dc5749396f7353295418e0227a and #237
-rw-r--r--vis-core.h5
-rw-r--r--vis-motions.c4
-rw-r--r--vis.c3
3 files changed, 7 insertions, 5 deletions
diff --git a/vis-core.h b/vis-core.h
index 08cf87b..6d3b35f 100644
--- 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
index 33784ff..933142c 100644
--- 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
index c3077a4..7c1ab78 100644
--- 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) {