vis: take symbolic keys into account when evaluating key prefixes
[vis.git] / config.def.h
blob0037949c8aa9f49eaf1ee2c2f0dcafd81994da08
1 /* Configure your desired default key bindings. */
3 #define ALIAS(name) .alias = name,
4 #define ACTION(id) .action = &vis_action[VIS_ACTION_##id],
6 static const char *keymaps[] = {
7 NULL
8 };
10 static const KeyBinding bindings_basic[] = {
11 { "<C-z>", ACTION(EDITOR_SUSPEND) },
12 { "<Down>", ACTION(CURSOR_LINE_DOWN) },
13 { "<End>", ACTION(CURSOR_LINE_END) },
14 { "<Home>", ACTION(CURSOR_LINE_BEGIN) },
15 { "<Left>", ACTION(CURSOR_CHAR_PREV) },
16 { "<PageDown>", ACTION(WINDOW_PAGE_DOWN) },
17 { "<PageUp>", ACTION(WINDOW_PAGE_UP) },
18 { "<Right>", ACTION(CURSOR_CHAR_NEXT) },
19 { "<S-Left>", ACTION(CURSOR_LONGWORD_START_PREV) },
20 { "<S-PageDown>", ACTION(WINDOW_HALFPAGE_DOWN) },
21 { "<S-PageUp>", ACTION(WINDOW_HALFPAGE_UP) },
22 { "<S-Right>", ACTION(CURSOR_LONGWORD_START_NEXT) },
23 { "<Up>", ACTION(CURSOR_LINE_UP) },
24 { 0 /* empty last element, array terminator */ },
27 static const KeyBinding bindings_motions[] = {
28 { "g|", ACTION(CURSOR_COLUMN) },
29 { "[{", ACTION(CURSOR_BLOCK_START) },
30 { "]}", ACTION(CURSOR_BLOCK_END) },
31 { "[(", ACTION(CURSOR_PARENTHESE_START) },
32 { "])", ACTION(CURSOR_PARENTHESE_END) },
33 { "$", ACTION(CURSOR_LINE_END) },
34 { "^", ACTION(CURSOR_LINE_START) },
35 { "}", ACTION(CURSOR_PARAGRAPH_NEXT) },
36 { "{", ACTION(CURSOR_PARAGRAPH_PREV) },
37 { "%", ACTION(CURSOR_PERCENT) },
38 { "#", ACTION(CURSOR_SEARCH_WORD_BACKWARD) },
39 { "*", ACTION(CURSOR_SEARCH_WORD_FORWARD) },
40 { ")", ACTION(CURSOR_SENTENCE_NEXT) },
41 { "(", ACTION(CURSOR_SENTENCE_PREV) },
42 { "?", ACTION(PROMPT_SEARCH_BACKWARD) },
43 { "/", ACTION(PROMPT_SEARCH_FORWARD) },
44 { ";", ACTION(TOTILL_REPEAT) },
45 { ",", ACTION(TOTILL_REVERSE) },
46 { "+", ALIAS("j^") },
47 { "-", ALIAS("k^") },
48 { " ", ALIAS("<Space>") },
49 { "<Space>", ALIAS("l") },
50 { "<Backspace>", ALIAS("h") },
51 { "B", ACTION(CURSOR_LONGWORD_START_PREV) },
52 { "b", ACTION(CURSOR_WORD_START_PREV) },
53 { "<C-h>", ALIAS("<Backspace>") },
54 { "<C-j>", ALIAS("j") },
55 { "<C-n>", ALIAS("j") },
56 { "<C-p>", ALIAS("k") },
57 { "E", ACTION(CURSOR_LONGWORD_END_NEXT) },
58 { "e", ACTION(CURSOR_WORD_END_NEXT) },
59 { "<Enter>", ALIAS("j") },
60 { "F", ACTION(TO_LEFT) },
61 { "f", ACTION(TO_RIGHT) },
62 { "go", ACTION(CURSOR_BYTE) },
63 { "gH", ACTION(CURSOR_BYTE_LEFT) },
64 { "gL", ACTION(CURSOR_BYTE_RIGHT) },
65 { "gh", ACTION(CURSOR_CODEPOINT_PREV) },
66 { "gl", ACTION(CURSOR_CODEPOINT_NEXT) },
67 { "g0", ACTION(CURSOR_SCREEN_LINE_BEGIN) },
68 { "g_", ACTION(CURSOR_LINE_FINISH) },
69 { "G", ACTION(CURSOR_LINE_LAST) },
70 { "g$", ACTION(CURSOR_SCREEN_LINE_END) },
71 { "gE", ACTION(CURSOR_LONGWORD_END_PREV) },
72 { "ge", ACTION(CURSOR_WORD_END_PREV) },
73 { "gg", ACTION(CURSOR_LINE_FIRST) },
74 { "gj", ACTION(CURSOR_SCREEN_LINE_DOWN) },
75 { "gk", ACTION(CURSOR_SCREEN_LINE_UP) },
76 { "gm", ACTION(CURSOR_SCREEN_LINE_MIDDLE) },
77 { "h", ACTION(CURSOR_CHAR_PREV) },
78 { "H", ACTION(CURSOR_WINDOW_LINE_TOP) },
79 { "j", ACTION(CURSOR_LINE_DOWN) },
80 { "k", ACTION(CURSOR_LINE_UP) },
81 { "l", ACTION(CURSOR_CHAR_NEXT) },
82 { "L", ACTION(CURSOR_WINDOW_LINE_BOTTOM) },
83 { "M", ACTION(CURSOR_WINDOW_LINE_MIDDLE) },
84 { "n", ACTION(CURSOR_SEARCH_REPEAT_FORWARD) },
85 { "N", ACTION(CURSOR_SEARCH_REPEAT_BACKWARD) },
86 { "T", ACTION(TILL_LEFT) },
87 { "t", ACTION(TILL_RIGHT) },
88 { "W", ACTION(CURSOR_LONGWORD_START_NEXT) },
89 { "w", ACTION(CURSOR_WORD_START_NEXT) },
90 { 0 /* empty last element, array terminator */ },
93 static const KeyBinding bindings_textobjects[] = {
94 { "a<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_OUTER) },
95 { "a`", ACTION(TEXT_OBJECT_BACKTICK_OUTER) },
96 { "a{", ACTION(TEXT_OBJECT_CURLY_BRACKET_OUTER) },
97 { "a(", ACTION(TEXT_OBJECT_PARANTHESE_OUTER) },
98 { "a\"", ACTION(TEXT_OBJECT_QUOTE_OUTER) },
99 { "a\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_OUTER) },
100 { "a[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_OUTER) },
101 { "a>", ALIAS("a<") },
102 { "a)", ALIAS("a(") },
103 { "a]", ALIAS("a[") },
104 { "a}", ALIAS("a{") },
105 { "ab", ALIAS("a(") },
106 { "aB", ALIAS("a{") },
107 { "ae", ACTION(TEXT_OBJECT_ENTIRE_OUTER) },
108 { "al", ACTION(TEXT_OBJECT_LINE_OUTER) },
109 { "ap", ACTION(TEXT_OBJECT_PARAGRAPH) },
110 { "as", ACTION(TEXT_OBJECT_SENTENCE) },
111 { "a<Tab>", ACTION(TEXT_OBJECT_INDENTATION) },
112 { "aW", ACTION(TEXT_OBJECT_LONGWORD_OUTER) },
113 { "aw", ACTION(TEXT_OBJECT_WORD_OUTER) },
114 { "gN", ACTION(TEXT_OBJECT_SEARCH_BACKWARD) },
115 { "gn", ACTION(TEXT_OBJECT_SEARCH_FORWARD) },
116 { "i<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_INNER) },
117 { "i`", ACTION(TEXT_OBJECT_BACKTICK_INNER) },
118 { "i{", ACTION(TEXT_OBJECT_CURLY_BRACKET_INNER) },
119 { "i(", ACTION(TEXT_OBJECT_PARANTHESE_INNER) },
120 { "i\"", ACTION(TEXT_OBJECT_QUOTE_INNER) },
121 { "i\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_INNER) },
122 { "i[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_INNER) },
123 { "i>", ALIAS("i<") },
124 { "i)", ALIAS("i(") },
125 { "i]", ALIAS("i[") },
126 { "i}", ALIAS("i{") },
127 { "ib", ALIAS("i(") },
128 { "iB", ALIAS("i{") },
129 { "ie", ACTION(TEXT_OBJECT_ENTIRE_INNER) },
130 { "il", ACTION(TEXT_OBJECT_LINE_INNER) },
131 { "ip", ACTION(TEXT_OBJECT_PARAGRAPH) },
132 { "is", ACTION(TEXT_OBJECT_SENTENCE) },
133 { "i<Tab>", ACTION(TEXT_OBJECT_INDENTATION) },
134 { "iW", ACTION(TEXT_OBJECT_LONGWORD_INNER) },
135 { "iw", ACTION(TEXT_OBJECT_WORD_INNER) },
136 { 0 /* empty last element, array terminator */ },
139 static const KeyBinding bindings_selections[] = {
140 { "m", ACTION(SELECTIONS_SAVE) },
141 { "M", ACTION(SELECTIONS_RESTORE) },
142 { "|", ACTION(SELECTIONS_UNION) },
143 { "&", ACTION(SELECTIONS_INTERSECT) },
144 { "!", ACTION(SELECTIONS_COMPLEMENT) },
145 { "\\", ACTION(SELECTIONS_MINUS) },
146 { "z|", ACTION(SELECTIONS_COMBINE_UNION) },
147 { "z&", ACTION(SELECTIONS_COMBINE_INTERSECT) },
148 { "z+", ACTION(SELECTIONS_COMBINE_LONGER) },
149 { "z-", ACTION(SELECTIONS_COMBINE_SHORTER) },
150 { "z<", ACTION(SELECTIONS_COMBINE_LEFTMOST) },
151 { "z>", ACTION(SELECTIONS_COMBINE_RIGHTMOST) },
152 // { "-", ACTION(SELECTIONS_ROTATE_LEFT) },
153 // { "+", ACTION(SELECTIONS_ROTATE_RIGHT) },
154 { "_", ACTION(SELECTIONS_TRIM) },
155 { "<S-Tab>", ACTION(SELECTIONS_ALIGN_INDENT_RIGHT) },
156 { "<Tab>", ACTION(SELECTIONS_ALIGN_INDENT_LEFT) },
157 { "g<", ACTION(JUMPLIST_PREV) },
158 { "gs", ACTION(JUMPLIST_SAVE) },
159 { "g>", ACTION(JUMPLIST_NEXT) },
160 { 0 /* empty last element, array terminator */ },
163 static const KeyBinding bindings_operators[] = {
164 { "0", ACTION(COUNT) },
165 { "1", ACTION(COUNT) },
166 { "2", ACTION(COUNT) },
167 { "3", ACTION(COUNT) },
168 { "4", ACTION(COUNT) },
169 { "5", ACTION(COUNT) },
170 { "6", ACTION(COUNT) },
171 { "7", ACTION(COUNT) },
172 { "8", ACTION(COUNT) },
173 { "9", ACTION(COUNT) },
174 { "~", ACTION(OPERATOR_CASE_SWAP) },
175 { "=", ALIAS("gq") },
176 { "<", ACTION(OPERATOR_SHIFT_LEFT) },
177 { ">", ACTION(OPERATOR_SHIFT_RIGHT) },
178 { "\"", ACTION(REGISTER) },
179 { "'", ACTION(MARK) },
180 { "c", ACTION(OPERATOR_CHANGE) },
181 { "d", ACTION(OPERATOR_DELETE) },
182 { "g~", ACTION(OPERATOR_CASE_SWAP) },
183 { "gp", ACTION(PUT_AFTER_END) },
184 { "gP", ACTION(PUT_BEFORE_END) },
185 { "gq", ALIAS(":| fmt<Enter>") },
186 { "gu", ACTION(OPERATOR_CASE_LOWER) },
187 { "gU", ACTION(OPERATOR_CASE_UPPER) },
188 { "p", ACTION(PUT_AFTER) },
189 { "P", ACTION(PUT_BEFORE) },
190 { "y", ACTION(OPERATOR_YANK) },
191 { 0 /* empty last element, array terminator */ },
194 static const KeyBinding bindings_operator_options[] = {
195 { "v", ACTION(MOTION_CHARWISE) },
196 { "V", ACTION(MOTION_LINEWISE) },
197 { 0 /* empty last element, array terminator */ },
200 static const KeyBinding bindings_normal[] = {
201 { "a", ACTION(APPEND_CHAR_NEXT) },
202 { "A", ACTION(APPEND_LINE_END) },
203 { "@", ACTION(MACRO_REPLAY) },
204 { ":", ACTION(PROMPT_SHOW) },
205 { ".", ACTION(REPEAT) },
206 { "~", ALIAS("<vis-operator-case-swap>ll") },
207 { "C", ALIAS("c$") },
208 { "<C-b>", ALIAS("<PageUp>") },
209 { "<C-c>", ACTION(SELECTIONS_REMOVE_COLUMN) },
210 { "<C-d>", ACTION(SELECTIONS_NEXT) },
211 { "<C-e>", ACTION(WINDOW_SLIDE_UP) },
212 { "<C-f>", ALIAS("<PageDown>") },
213 { "<C-j>", ACTION(SELECTIONS_NEW_LINE_BELOW) },
214 { "<C-k>", ACTION(SELECTIONS_NEW_LINE_ABOVE) },
215 { "<C-l>", ACTION(SELECTIONS_REMOVE_COLUMN_EXCEPT) },
216 { "<C-n>", ACTION(SELECTIONS_MATCH_WORD) },
217 { "<C-p>", ACTION(SELECTIONS_REMOVE_LAST) },
218 { "<C-r>", ACTION(REDO) },
219 { "<C-u>", ACTION(SELECTIONS_PREV) },
220 { "<C-w><Backspace>", ALIAS("<C-w>k") },
221 { "<C-w>c", ALIAS(":q<Enter>") },
222 { "<C-w><C-h>", ALIAS("<C-w>k") },
223 { "<C-w><C-j>", ALIAS("<C-w>j") },
224 { "<C-w><C-k>", ALIAS("<C-w>k") },
225 { "<C-w><C-l>", ALIAS("<C-w>j") },
226 { "<C-w><C-w>", ALIAS("<C-w>j") },
227 { "<C-w>h", ALIAS("<C-w>k") },
228 { "<C-w>j", ACTION(WINDOW_NEXT) },
229 { "<C-w>k", ACTION(WINDOW_PREV) },
230 { "<C-w>l", ALIAS("<C-w>j") },
231 { "<C-w>n", ALIAS(":open<Enter>") },
232 { "<C-w>s", ALIAS(":split<Enter>") },
233 { "<C-w>v", ALIAS(":vsplit<Enter>") },
234 { "<C-w>w", ALIAS("<C-w>j") },
235 { "<C-y>", ACTION(WINDOW_SLIDE_DOWN) },
236 { "D", ALIAS("d$") },
237 { "<Delete>", ALIAS("x") },
238 { "<Escape>", ACTION(SELECTIONS_REMOVE_ALL) },
239 { "<F1>", ALIAS(":help<Enter>") },
240 { "ga", ACTION(UNICODE_INFO) },
241 { "g8", ACTION(UTF8_INFO) },
242 { "g-", ACTION(EARLIER) },
243 { "g+", ACTION(LATER) },
244 { "gn", ALIAS("vgn") },
245 { "gN", ALIAS("vgN") },
246 { "gv", ALIAS("v'^M") },
247 { "I", ACTION(INSERT_LINE_START) },
248 { "i", ACTION(MODE_INSERT) },
249 { "J", ACTION(JOIN_LINES) },
250 { "gJ", ACTION(JOIN_LINES_TRIM) },
251 { "<M-C-j>", ACTION(SELECTIONS_NEW_LINE_BELOW_LAST) },
252 { "<M-C-k>", ACTION(SELECTIONS_NEW_LINE_ABOVE_FIRST) },
253 { "O", ACTION(OPEN_LINE_ABOVE) },
254 { "o", ACTION(OPEN_LINE_BELOW) },
255 { "q", ACTION(MACRO_RECORD) },
256 { "R", ACTION(MODE_REPLACE) },
257 { "r", ACTION(REPLACE_CHAR) },
258 { "S", ALIAS("^c$") },
259 { "s", ALIAS("cl") },
260 { "<Tab>", ACTION(SELECTIONS_ALIGN) },
261 { "u", ACTION(UNDO) },
262 { "v", ACTION(MODE_VISUAL) },
263 { "V", ACTION(MODE_VISUAL_LINE) },
264 { "x", ACTION(DELETE_CHAR_NEXT) },
265 { "X", ALIAS("dh") },
266 { "Y", ALIAS("y$") },
267 { "zb", ACTION(WINDOW_REDRAW_BOTTOM) },
268 { "ZQ", ALIAS(":q!<Enter>") },
269 { "zt", ACTION(WINDOW_REDRAW_TOP) },
270 { "zz", ACTION(WINDOW_REDRAW_CENTER) },
271 { "ZZ", ALIAS(":wq<Enter>") },
272 { 0 /* empty last element, array terminator */ },
275 static const KeyBinding bindings_visual[] = {
276 { "A", ACTION(SELECTIONS_NEW_LINES_END) },
277 { "@", ACTION(MACRO_REPLAY) },
278 { ":", ACTION(PROMPT_SHOW) },
279 { "-", ACTION(SELECTIONS_ROTATE_LEFT) },
280 { "+", ACTION(SELECTIONS_ROTATE_RIGHT) },
281 { "<", ALIAS("<vis-operator-shift-left>gv") },
282 { ">", ALIAS("<vis-operator-shift-right>gv") },
283 { "<Backspace>", ALIAS("d") },
284 { "<C-b>", ALIAS("<PageUp>") },
285 { "<C-c>", ACTION(SELECTIONS_REMOVE_COLUMN) },
286 { "<C-d>", ACTION(SELECTIONS_NEXT) },
287 { "<C-f>", ALIAS("<PageDown>") },
288 { "<C-h>", ALIAS("<Backspace>") },
289 { "<C-j>", ALIAS("<C-d>") },
290 { "<C-k>", ALIAS("<C-u>") },
291 { "<C-l>", ACTION(SELECTIONS_REMOVE_COLUMN_EXCEPT) },
292 { "<C-n>", ACTION(SELECTIONS_NEW_MATCH_NEXT) },
293 { "<C-p>", ACTION(SELECTIONS_REMOVE_LAST) },
294 { "<C-u>", ACTION(SELECTIONS_PREV) },
295 { "<C-x>", ACTION(SELECTIONS_NEW_MATCH_SKIP) },
296 { "<Delete>", ALIAS("<Backspace>") },
297 { "<Escape>", ACTION(MODE_NORMAL) },
298 { "I", ACTION(SELECTIONS_NEW_LINES_BEGIN) },
299 { "J", ACTION(JOIN_LINES) },
300 { "gJ", ACTION(JOIN_LINES_TRIM) },
301 { "o", ACTION(SELECTION_FLIP) },
302 { "q", ACTION(MACRO_RECORD) },
303 { "r", ACTION(REPLACE_CHAR) },
304 { "s", ALIAS("c") },
305 { "V", ACTION(MODE_VISUAL_LINE) },
306 { "v", ALIAS("<Escape>") },
307 { "x", ALIAS("d") },
308 { 0 /* empty last element, array terminator */ },
311 static const KeyBinding bindings_visual_line[] = {
312 { "v", ACTION(MODE_VISUAL) },
313 { "V", ACTION(MODE_NORMAL) },
314 { 0 /* empty last element, array terminator */ },
317 static const KeyBinding bindings_readline[] = {
318 { "<Backspace>", ACTION(DELETE_CHAR_PREV) },
319 { "<C-c>", ALIAS("<Escape>") },
320 { "<C-d>", ACTION(DELETE_CHAR_NEXT) },
321 { "<C-h>", ALIAS("<Backspace>") },
322 { "<C-u>", ACTION(DELETE_LINE_BEGIN) },
323 { "<C-v>", ACTION(INSERT_VERBATIM) },
324 { "<C-w>", ACTION(DELETE_WORD_PREV) },
325 { "<Delete>", ACTION(DELETE_CHAR_NEXT) },
326 { "<Escape>", ACTION(MODE_NORMAL) },
327 { 0 /* empty last element, array terminator */ },
330 static const KeyBinding bindings_insert[] = {
331 { "<C-d>", ALIAS("<vis-operator-shift-left><vis-operator-shift-left>") },
332 { "<C-i>", ALIAS("<Tab>") },
333 { "<C-j>", ALIAS("<Enter>") },
334 { "<C-m>", ALIAS("<Enter>") },
335 { "<C-r>", ACTION(INSERT_REGISTER) },
336 { "<C-t>", ALIAS("<vis-operator-shift-right><vis-operator-shift-right>") },
337 { "<C-x><C-e>", ACTION(WINDOW_SLIDE_UP) },
338 { "<C-x><C-y>", ACTION(WINDOW_SLIDE_DOWN) },
339 { "<Enter>", ACTION(INSERT_NEWLINE) },
340 { "<Escape>", ACTION(MODE_NORMAL) },
341 { "<S-Tab>", ACTION(SELECTIONS_ALIGN_INDENT_LEFT) },
342 { "<Tab>", ACTION(INSERT_TAB) },
343 { 0 /* empty last element, array terminator */ },
346 static const KeyBinding bindings_replace[] = {
347 { 0 /* empty last element, array terminator */ },
350 /* For each mode we list a all key bindings, if a key is bound in more than
351 * one array the first definition is used and further ones are ignored. */
352 static const KeyBinding **default_bindings[] = {
353 [VIS_MODE_OPERATOR_PENDING] = (const KeyBinding*[]){
354 bindings_operator_options,
355 bindings_operators,
356 bindings_textobjects,
357 bindings_motions,
358 bindings_basic,
359 NULL,
361 [VIS_MODE_NORMAL] = (const KeyBinding*[]){
362 bindings_normal,
363 bindings_selections,
364 bindings_operators,
365 bindings_motions,
366 bindings_basic,
367 NULL,
369 [VIS_MODE_VISUAL] = (const KeyBinding*[]){
370 bindings_visual,
371 bindings_selections,
372 bindings_textobjects,
373 bindings_operators,
374 bindings_motions,
375 bindings_basic,
376 NULL,
378 [VIS_MODE_VISUAL_LINE] = (const KeyBinding*[]){
379 bindings_visual_line,
380 NULL,
382 [VIS_MODE_INSERT] = (const KeyBinding*[]){
383 bindings_insert,
384 bindings_readline,
385 bindings_basic,
386 NULL,
388 [VIS_MODE_REPLACE] = (const KeyBinding*[]){
389 bindings_replace,
390 NULL,