aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2020-08-29 13:39:50 +0200
committerMarc André Tanner <mat@brain-dump.org>2020-08-29 13:52:30 +0200
commit08d2e6964eee74a156e6ca4996e90f5e0a2d676f (patch)
tree86665d0dc0de61447139f57b80428a29babbe2eb
parent6f0f448ef22a324cefce9e6ab7c89cae7d00a034 (diff)
downloadvis-08d2e6964eee74a156e6ca4996e90f5e0a2d676f.tar.gz
vis-08d2e6964eee74a156e6ca4996e90f5e0a2d676f.tar.xz
vis: implement C-n in normal mode with a mapping to viw
-rw-r--r--config.def.h2
-rw-r--r--main.c20
2 files changed, 1 insertions, 21 deletions
diff --git a/config.def.h b/config.def.h
index 3717404..6a4555e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -184,7 +184,7 @@ static const KeyBinding bindings_normal[] = {
{ "<C-j>", ACTION(SELECTIONS_NEW_LINE_BELOW) },
{ "<C-k>", ACTION(SELECTIONS_NEW_LINE_ABOVE) },
{ "<C-l>", ACTION(SELECTIONS_REMOVE_COLUMN_EXCEPT) },
- { "<C-n>", ACTION(SELECTIONS_MATCH_WORD) },
+ { "<C-n>", ALIAS("viw") },
{ "<C-p>", ACTION(SELECTIONS_REMOVE_LAST) },
{ "<C-r>", ACTION(REDO) },
{ "<C-u>", ACTION(SELECTIONS_PREV) },
diff --git a/main.c b/main.c
index d838cc2..4e9f6df 100644
--- a/main.c
+++ b/main.c
@@ -66,8 +66,6 @@ static const char *selections_remove_column(Vis*, const char *keys, const Arg *a
static const char *selections_remove_column_except(Vis*, const char *keys, const Arg *arg);
/* move to the previous (arg->i < 0) or next (arg->i > 0) selection */
static const char *selections_navigate(Vis*, const char *keys, const Arg *arg);
-/* select the word the selection is currently over */
-static const char *selections_match_word(Vis*, const char *keys, const Arg *arg);
/* select the next region matching the current selection */
static const char *selections_match_next(Vis*, const char *keys, const Arg *arg);
/* clear current selection but select next match */
@@ -256,7 +254,6 @@ enum {
VIS_ACTION_WINDOW_SLIDE_DOWN,
VIS_ACTION_PUT_AFTER,
VIS_ACTION_PUT_BEFORE,
- VIS_ACTION_SELECTIONS_MATCH_WORD,
VIS_ACTION_SELECTIONS_NEW_LINE_ABOVE,
VIS_ACTION_SELECTIONS_NEW_LINE_ABOVE_FIRST,
VIS_ACTION_SELECTIONS_NEW_LINE_BELOW,
@@ -890,11 +887,6 @@ static const KeyAction vis_action[] = {
VIS_HELP("Put text before the cursor")
operator, { .i = VIS_OP_PUT_BEFORE }
},
- [VIS_ACTION_SELECTIONS_MATCH_WORD] = {
- "vis-selections-select-word",
- VIS_HELP("Select word under cursor")
- selections_match_word,
- },
[VIS_ACTION_SELECTIONS_NEW_LINE_ABOVE] = {
"vis-selection-new-lines-above",
VIS_HELP("Create a new selection on the line above")
@@ -1333,18 +1325,6 @@ static const char *selections_clear(Vis *vis, const char *keys, const Arg *arg)
return keys;
}
-static const char *selections_match_word(Vis *vis, const char *keys, const Arg *arg) {
- Text *txt = vis_text(vis);
- View *view = vis_view(vis);
- for (Selection *s = view_selections(view); s; s = view_selections_next(s)) {
- Filerange word = text_object_word(txt, view_cursors_pos(s));
- if (text_range_valid(&word))
- view_selections_set(s, &word);
- }
- vis_mode_switch(vis, VIS_MODE_VISUAL);
- return keys;
-}
-
static const Selection *selection_new_primary(View *view, Filerange *r) {
Text *txt = view_text(view);
size_t pos = text_char_prev(txt, r->end);