vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 4cb19e899d31c19dc23f17cfa587d1cb7cd88b40 parent 07131fb314aec8c85cf59cf71dc0ccaaf8268dc1 Author: Marc André Tanner <mat@brain-dump.org> Date: Thu, 14 Apr 2016 21:36:19 +0200 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 Diffstat:
| M | config.def.h | | | 3 | ++- |
| M | vis-cmds.c | | | 7 | +++---- |
| M | vis.c | | | 2 | +- |
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git 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 @@ -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 @@ -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;