aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-14 21:36:19 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-14 21:36:19 +0200
commitbd1d849b2033b04a372542c59d458d4f8279c937 (patch)
tree4485bb3b20436d76ad59fd5b9ea9d75f792aa17c
parentd7c917ea63e0374fc03622d4f21df8ac4c574fae (diff)
downloadvis-bd1d849b2033b04a372542c59d458d4f8279c937.tar.gz
vis-bd1d849b2033b04a372542c59d458d4f8279c937.tar.xz
vis: allow mapping of <Space>
One should generally use <Space> in mappings: :map! normal <Space> h except for insert/replace mode where a literal space has to be used: :map! insert " " foo
-rw-r--r--config.def.h3
-rw-r--r--vis-cmds.c7
-rw-r--r--vis.c2
3 files changed, 6 insertions, 6 deletions
diff --git a/config.def.h b/config.def.h
index 2ca1a82..f01d556 100644
--- a/config.def.h
+++ b/config.def.h
@@ -51,7 +51,8 @@ static const KeyBinding bindings_motions[] = {
{ ",", ACTION(TOTILL_REVERSE) },
{ "+", ALIAS("j^") },
{ "-", ALIAS("k^") },
- { " ", ALIAS("l") },
+ { " ", ALIAS("<Space>") },
+ { "<Space>", ALIAS("l") },
{ "<Backspace>", ALIAS("h") },
{ "B", ACTION(CURSOR_LONGWORD_START_PREV) },
{ "b", ACTION(CURSOR_WORD_START_PREV) },
diff --git a/vis-cmds.c b/vis-cmds.c
index 0ef6139..e58d20a 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -471,16 +471,15 @@ static bool cmd_earlier_later(Vis *vis, Win *win, Command *cmd, const char *argv
}
static bool print_keylayout(const char *key, void *value, void *data) {
- return text_appendf(data, " %-15s\t%s\n", key, (char*)value);
+ return text_appendf(data, " %-18s\t%s\n", key[0] == ' ' ? "␣" : key, (char*)value);
}
static bool print_keybinding(const char *key, void *value, void *data) {
- Text *txt = data;
KeyBinding *binding = value;
const char *desc = binding->alias;
if (!desc && binding->action)
desc = binding->action->help;
- return text_appendf(txt, " %-15s\t%s\n", key[0] == ' ' ? "<Space>" : key, desc ? desc : "");
+ return text_appendf(data, " %-18s\t%s\n", key[0] == ' ' ? "␣" : key, desc ? desc : "");
}
static void print_mode(Mode *mode, Text *txt) {
@@ -507,7 +506,7 @@ static bool cmd_help(Vis *vis, Win *win, Command *cmd, const char *argv[], Curso
for (int i = 0; i < LENGTH(vis_modes); i++) {
Mode *mode = &vis_modes[i];
if (mode->help)
- text_appendf(txt, " %-15s\t%s\n", mode->name, mode->help);
+ text_appendf(txt, " %-18s\t%s\n", mode->name, mode->help);
}
diff --git a/vis.c b/vis.c
index 4926555..c59133b 100644
--- a/vis.c
+++ b/vis.c
@@ -361,7 +361,7 @@ Vis *vis_new(Ui *ui, VisEvent *event) {
goto err;
if (!(vis->search_file = file_new_internal(vis, NULL)))
goto err;
- if (!(vis->keymap = map_new()))
+ if (!(vis->keymap = map_new()) || !map_put(vis->keymap, " ", "<Space>"))
goto err;
vis->mode_prev = vis->mode = &vis_modes[VIS_MODE_NORMAL];
vis->event = event;