vis-lua: expose current input_queue content
[vis.git] / config.def.h
blob9e055dfa3bf7503e4d7b08fa0cceb89619f97010
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_PARENTHESIS_START) },
32 { "])", ACTION(CURSOR_PARENTHESIS_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_PARENTHESIS_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_OUTER) },
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_PARENTHESIS_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 { "~", ALIAS("g~") },
175 { "=", ALIAS(":|fmt<Enter>") },
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~", ALIAS(":|tr '[:lower:][:upper:]' '[:upper:][:lower:]'<Enter>") },
183 { "gu", ALIAS(":|tr '[:upper:]' '[:lower:]'<Enter>")},
184 { "gU", ALIAS(":|tr '[:lower:]' '[:upper:]'<Enter>")},
185 { "p", ACTION(PUT_AFTER) },
186 { "P", ACTION(PUT_BEFORE) },
187 { "y", ACTION(OPERATOR_YANK) },
188 { 0 /* empty last element, array terminator */ },
191 static const KeyBinding bindings_normal[] = {
192 { "a", ACTION(APPEND_CHAR_NEXT) },
193 { "A", ACTION(APPEND_LINE_END) },
194 { "@", ACTION(MACRO_REPLAY) },
195 { ":", ACTION(PROMPT_SHOW) },
196 { ".", ACTION(REPEAT) },
197 { "C", ALIAS("c$") },
198 { "<C-b>", ALIAS("<PageUp>") },
199 { "<C-c>", ACTION(SELECTIONS_REMOVE_COLUMN) },
200 { "<C-d>", ACTION(SELECTIONS_NEXT) },
201 { "<C-e>", ACTION(WINDOW_SLIDE_UP) },
202 { "<C-f>", ALIAS("<PageDown>") },
203 { "<C-j>", ACTION(SELECTIONS_NEW_LINE_BELOW) },
204 { "<C-k>", ACTION(SELECTIONS_NEW_LINE_ABOVE) },
205 { "<C-l>", ACTION(SELECTIONS_REMOVE_COLUMN_EXCEPT) },
206 { "<C-n>", ACTION(SELECTIONS_MATCH_WORD) },
207 { "<C-p>", ACTION(SELECTIONS_REMOVE_LAST) },
208 { "<C-r>", ACTION(REDO) },
209 { "<C-u>", ACTION(SELECTIONS_PREV) },
210 { "<C-w><Backspace>", ALIAS("<C-w>k") },
211 { "<C-w>c", ALIAS(":q<Enter>") },
212 { "<C-w><C-h>", ALIAS("<C-w>k") },
213 { "<C-w><C-j>", ALIAS("<C-w>j") },
214 { "<C-w><C-k>", ALIAS("<C-w>k") },
215 { "<C-w><C-l>", ALIAS("<C-w>j") },
216 { "<C-w><C-w>", ALIAS("<C-w>j") },
217 { "<C-w>h", ALIAS("<C-w>k") },
218 { "<C-w>j", ACTION(WINDOW_NEXT) },
219 { "<C-w>k", ACTION(WINDOW_PREV) },
220 { "<C-w>l", ALIAS("<C-w>j") },
221 { "<C-w>n", ALIAS(":open<Enter>") },
222 { "<C-w>s", ALIAS(":split<Enter>") },
223 { "<C-w>v", ALIAS(":vsplit<Enter>") },
224 { "<C-w>w", ALIAS("<C-w>j") },
225 { "<C-y>", ACTION(WINDOW_SLIDE_DOWN) },
226 { "D", ALIAS("d$") },
227 { "<Delete>", ALIAS("x") },
228 { "<Escape>", ACTION(SELECTIONS_REMOVE_ALL) },
229 { "<F1>", ALIAS(":help<Enter>") },
230 { "ga", ACTION(UNICODE_INFO) },
231 { "g8", ACTION(UTF8_INFO) },
232 { "g-", ACTION(EARLIER) },
233 { "g+", ACTION(LATER) },
234 { "gn", ALIAS("vgn") },
235 { "gN", ALIAS("vgN") },
236 { "gv", ALIAS("v'^M") },
237 { "I", ACTION(INSERT_LINE_START) },
238 { "i", ACTION(MODE_INSERT) },
239 { "J", ACTION(JOIN_LINES) },
240 { "gJ", ACTION(JOIN_LINES_TRIM) },
241 { "<M-C-j>", ACTION(SELECTIONS_NEW_LINE_BELOW_LAST) },
242 { "<M-C-k>", ACTION(SELECTIONS_NEW_LINE_ABOVE_FIRST) },
243 { "O", ACTION(OPEN_LINE_ABOVE) },
244 { "o", ACTION(OPEN_LINE_BELOW) },
245 { "q", ACTION(MACRO_RECORD) },
246 { "R", ACTION(MODE_REPLACE) },
247 { "r", ACTION(REPLACE_CHAR) },
248 { "S", ALIAS("^c$") },
249 { "s", ALIAS("cl") },
250 { "<Tab>", ACTION(SELECTIONS_ALIGN) },
251 { "u", ACTION(UNDO) },
252 { "v", ACTION(MODE_VISUAL) },
253 { "V", ACTION(MODE_VISUAL_LINE) },
254 { "x", ACTION(DELETE_CHAR_NEXT) },
255 { "X", ALIAS("dh") },
256 { "Y", ALIAS("y$") },
257 { "zb", ACTION(WINDOW_REDRAW_BOTTOM) },
258 { "ZQ", ALIAS(":q!<Enter>") },
259 { "zt", ACTION(WINDOW_REDRAW_TOP) },
260 { "zz", ACTION(WINDOW_REDRAW_CENTER) },
261 { "ZZ", ALIAS(":wq<Enter>") },
262 { 0 /* empty last element, array terminator */ },
265 static const KeyBinding bindings_visual[] = {
266 { "A", ACTION(SELECTIONS_NEW_LINES_END) },
267 { "@", ACTION(MACRO_REPLAY) },
268 { ":", ACTION(PROMPT_SHOW) },
269 { "-", ACTION(SELECTIONS_ROTATE_LEFT) },
270 { "+", ACTION(SELECTIONS_ROTATE_RIGHT) },
271 { "<", ALIAS("<vis-operator-shift-left>gv") },
272 { ">", ALIAS("<vis-operator-shift-right>gv") },
273 { "<Backspace>", ALIAS("d") },
274 { "<C-b>", ALIAS("<PageUp>") },
275 { "<C-c>", ACTION(SELECTIONS_REMOVE_COLUMN) },
276 { "<C-d>", ACTION(SELECTIONS_NEXT) },
277 { "<C-f>", ALIAS("<PageDown>") },
278 { "<C-h>", ALIAS("<Backspace>") },
279 { "<C-j>", ALIAS("<C-d>") },
280 { "<C-k>", ALIAS("<C-u>") },
281 { "<C-l>", ACTION(SELECTIONS_REMOVE_COLUMN_EXCEPT) },
282 { "<C-n>", ACTION(SELECTIONS_NEW_MATCH_NEXT) },
283 { "<C-p>", ACTION(SELECTIONS_REMOVE_LAST) },
284 { "<C-u>", ACTION(SELECTIONS_PREV) },
285 { "<C-x>", ACTION(SELECTIONS_NEW_MATCH_SKIP) },
286 { "<Delete>", ALIAS("<Backspace>") },
287 { "<Escape>", ACTION(MODE_NORMAL) },
288 { "I", ACTION(SELECTIONS_NEW_LINES_BEGIN) },
289 { "J", ACTION(JOIN_LINES) },
290 { "gJ", ACTION(JOIN_LINES_TRIM) },
291 { "o", ACTION(SELECTION_FLIP) },
292 { "q", ACTION(MACRO_RECORD) },
293 { "r", ACTION(REPLACE_CHAR) },
294 { "s", ALIAS("c") },
295 { "V", ACTION(MODE_VISUAL_LINE) },
296 { "v", ALIAS("<Escape>") },
297 { "x", ALIAS("d") },
298 { 0 /* empty last element, array terminator */ },
301 static const KeyBinding bindings_visual_line[] = {
302 { "v", ACTION(MODE_VISUAL) },
303 { "V", ACTION(MODE_NORMAL) },
304 { 0 /* empty last element, array terminator */ },
307 static const KeyBinding bindings_readline[] = {
308 { "<Backspace>", ACTION(DELETE_CHAR_PREV) },
309 { "<C-c>", ALIAS("<Escape>") },
310 { "<C-d>", ACTION(DELETE_CHAR_NEXT) },
311 { "<C-h>", ALIAS("<Backspace>") },
312 { "<C-u>", ACTION(DELETE_LINE_BEGIN) },
313 { "<C-v>", ACTION(INSERT_VERBATIM) },
314 { "<C-w>", ACTION(DELETE_WORD_PREV) },
315 { "<Delete>", ACTION(DELETE_CHAR_NEXT) },
316 { "<Escape>", ACTION(MODE_NORMAL) },
317 { 0 /* empty last element, array terminator */ },
320 static const KeyBinding bindings_insert[] = {
321 { "<C-d>", ALIAS("<vis-operator-shift-left><vis-operator-shift-left>") },
322 { "<C-i>", ALIAS("<Tab>") },
323 { "<C-j>", ALIAS("<vis-insert-verbatim>u000a") },
324 { "<C-m>", ALIAS("<Enter>") },
325 { "<C-r>", ACTION(INSERT_REGISTER) },
326 { "<C-t>", ALIAS("<vis-operator-shift-right><vis-operator-shift-right>") },
327 { "<C-x><C-e>", ACTION(WINDOW_SLIDE_UP) },
328 { "<C-x><C-y>", ACTION(WINDOW_SLIDE_DOWN) },
329 { "<Enter>", ACTION(INSERT_NEWLINE) },
330 { "<Escape>", ACTION(MODE_NORMAL) },
331 { "<S-Tab>", ACTION(SELECTIONS_ALIGN_INDENT_LEFT) },
332 { "<Tab>", ACTION(INSERT_TAB) },
333 { 0 /* empty last element, array terminator */ },
336 static const KeyBinding bindings_replace[] = {
337 { 0 /* empty last element, array terminator */ },
340 /* For each mode we list a all key bindings, if a key is bound in more than
341 * one array the first definition is used and further ones are ignored. */
342 static const KeyBinding **default_bindings[] = {
343 [VIS_MODE_OPERATOR_PENDING] = (const KeyBinding*[]){
344 bindings_operators,
345 bindings_textobjects,
346 bindings_motions,
347 bindings_basic,
348 NULL,
350 [VIS_MODE_NORMAL] = (const KeyBinding*[]){
351 bindings_normal,
352 bindings_selections,
353 bindings_operators,
354 bindings_motions,
355 bindings_basic,
356 NULL,
358 [VIS_MODE_VISUAL] = (const KeyBinding*[]){
359 bindings_visual,
360 bindings_selections,
361 bindings_textobjects,
362 bindings_operators,
363 bindings_motions,
364 bindings_basic,
365 NULL,
367 [VIS_MODE_VISUAL_LINE] = (const KeyBinding*[]){
368 bindings_visual_line,
369 NULL,
371 [VIS_MODE_INSERT] = (const KeyBinding*[]){
372 bindings_insert,
373 bindings_readline,
374 bindings_basic,
375 NULL,
377 [VIS_MODE_REPLACE] = (const KeyBinding*[]){
378 bindings_replace,
379 NULL,