aboutsummaryrefslogtreecommitdiff
path: root/config.def.h
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-05 15:02:43 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-05 15:02:43 +0200
commit66a76466bcd555c8eea429daf1f4fa369a4fd855 (patch)
tree59628b4cce416f53eaf202cf7a137a995c6e2acc /config.def.h
parent6b7561195d75dedec40adba8fa06c6eab1e82d72 (diff)
downloadvis-66a76466bcd555c8eea429daf1f4fa369a4fd855.tar.gz
vis-66a76466bcd555c8eea429daf1f4fa369a4fd855.tar.xz
Implement movement to column in line
Diffstat (limited to 'config.def.h')
-rw-r--r--config.def.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index 9cd3497..c93f97a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -104,6 +104,17 @@ static size_t line(const Arg *arg) {
return pos;
}
+static size_t column(const Arg *arg) {
+ char c;
+ VisWin *win = vis->win;
+ size_t pos = window_cursor_get(win->win);
+ Iterator it = text_iterator_get(win->text, text_line_begin(win->text, pos));
+ while (action.count-- > 0 && text_iterator_byte_get(&it, &c) && c != '\n')
+ text_iterator_byte_next(&it, NULL);
+ action.count = 0;
+ return it.pos;
+}
+
static Operator ops[] = {
[OP_DELETE] = { op_delete, false },
[OP_CHANGE] = { op_change, false },
@@ -119,6 +130,7 @@ enum {
MOVE_LINE_FINISH,
MOVE_LINE_END,
MOVE_LINE,
+ MOVE_COLUMN,
MOVE_CHAR_PREV,
MOVE_CHAR_NEXT,
MOVE_WORD_START_PREV,
@@ -148,6 +160,7 @@ static Movement moves[] = {
[MOVE_LINE_FINISH] = { .txt = text_line_finish, .type = LINEWISE },
[MOVE_LINE_END] = { .txt = text_line_end, .type = LINEWISE },
[MOVE_LINE] = { .cmd = line, .type = LINEWISE },
+ [MOVE_COLUMN] = { .cmd = column, .type = CHARWISE },
[MOVE_CHAR_PREV] = { .win = window_char_prev },
[MOVE_CHAR_NEXT] = { .win = window_char_next },
[MOVE_WORD_START_PREV] = { .txt = text_word_start_prev, .type = CHARWISE },
@@ -472,6 +485,7 @@ static KeyBinding vis_movements[] = {
{ { NONE(')') }, movement, { .i = MOVE_SENTENCE_NEXT } },
{ { NONE('g'), NONE('g') }, movement, { .i = MOVE_FILE_BEGIN } },
{ { NONE('G') }, movement, { .i = MOVE_LINE } },
+ { { NONE('|') }, movement, { .i = MOVE_COLUMN } },
{ { NONE('f') }, movement_key, { .i = MOVE_RIGHT_TO } },
{ { NONE('F') }, movement_key, { .i = MOVE_LEFT_TO } },
{ { NONE('t') }, movement_key, { .i = MOVE_RIGHT_TILL } },