Link to C API documentation of master branch
[vis.git] / config.def.h
blobffc957727e611a1a504da06b19d1e3d47ff38f68
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 { "|", 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(MARK_GOTO) },
43 { "'", ACTION(MARK_GOTO_LINE) },
44 { "?", ACTION(PROMPT_SEARCH_BACKWARD) },
45 { "/", ACTION(PROMPT_SEARCH_FORWARD) },
46 { ";", ACTION(TOTILL_REPEAT) },
47 { ",", ACTION(TOTILL_REVERSE) },
48 { "+", ALIAS("j^") },
49 { "-", ALIAS("k^") },
50 { " ", ALIAS("<Space>") },
51 { "<Space>", ALIAS("l") },
52 { "<Backspace>", ALIAS("h") },
53 { "B", ACTION(CURSOR_LONGWORD_START_PREV) },
54 { "b", ACTION(CURSOR_WORD_START_PREV) },
55 { "<C-h>", ALIAS("<Backspace>") },
56 { "<C-j>", ALIAS("j") },
57 { "<C-n>", ALIAS("j") },
58 { "<C-p>", ALIAS("k") },
59 { "E", ACTION(CURSOR_LONGWORD_END_NEXT) },
60 { "e", ACTION(CURSOR_WORD_END_NEXT) },
61 { "<Enter>", ALIAS("j") },
62 { "F", ACTION(TO_LEFT) },
63 { "f", ACTION(TO_RIGHT) },
64 { "go", ACTION(CURSOR_BYTE) },
65 { "gH", ACTION(CURSOR_BYTE_LEFT) },
66 { "gL", ACTION(CURSOR_BYTE_RIGHT) },
67 { "gh", ACTION(CURSOR_CODEPOINT_PREV) },
68 { "gl", ACTION(CURSOR_CODEPOINT_NEXT) },
69 { "g0", ACTION(CURSOR_SCREEN_LINE_BEGIN) },
70 { "g_", ACTION(CURSOR_LINE_FINISH) },
71 { "G", ACTION(CURSOR_LINE_LAST) },
72 { "g$", ACTION(CURSOR_SCREEN_LINE_END) },
73 { "g<Down>", ALIAS("gj") },
74 { "gE", ACTION(CURSOR_LONGWORD_END_PREV) },
75 { "ge", ACTION(CURSOR_WORD_END_PREV) },
76 { "gg", ACTION(CURSOR_LINE_FIRST) },
77 { "gj", ACTION(CURSOR_SCREEN_LINE_DOWN) },
78 { "gk", ACTION(CURSOR_SCREEN_LINE_UP) },
79 { "gm", ACTION(CURSOR_SCREEN_LINE_MIDDLE) },
80 { "g<Up>", ALIAS("gk") },
81 { "h", ACTION(CURSOR_CHAR_PREV) },
82 { "H", ACTION(CURSOR_WINDOW_LINE_TOP) },
83 { "j", ACTION(CURSOR_LINE_DOWN) },
84 { "k", ACTION(CURSOR_LINE_UP) },
85 { "l", ACTION(CURSOR_CHAR_NEXT) },
86 { "L", ACTION(CURSOR_WINDOW_LINE_BOTTOM) },
87 { "M", ACTION(CURSOR_WINDOW_LINE_MIDDLE) },
88 { "n", ACTION(CURSOR_SEARCH_REPEAT_FORWARD) },
89 { "N", ACTION(CURSOR_SEARCH_REPEAT_BACKWARD) },
90 { "T", ACTION(TILL_LEFT) },
91 { "t", ACTION(TILL_RIGHT) },
92 { "W", ACTION(CURSOR_LONGWORD_START_NEXT) },
93 { "w", ACTION(CURSOR_WORD_START_NEXT) },
94 { 0 /* empty last element, array terminator */ },
97 static const KeyBinding bindings_textobjects[] = {
98 { "a<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_OUTER) },
99 { "a`", ACTION(TEXT_OBJECT_BACKTICK_OUTER) },
100 { "a{", ACTION(TEXT_OBJECT_CURLY_BRACKET_OUTER) },
101 { "a(", ACTION(TEXT_OBJECT_PARANTHESE_OUTER) },
102 { "a\"", ACTION(TEXT_OBJECT_QUOTE_OUTER) },
103 { "a\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_OUTER) },
104 { "a[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_OUTER) },
105 { "a>", ALIAS("a<") },
106 { "a)", ALIAS("a(") },
107 { "a]", ALIAS("a[") },
108 { "a}", ALIAS("a{") },
109 { "ab", ALIAS("a(") },
110 { "aB", ALIAS("a{") },
111 { "ae", ACTION(TEXT_OBJECT_ENTIRE_OUTER) },
112 { "al", ACTION(TEXT_OBJECT_LINE_OUTER) },
113 { "ap", ACTION(TEXT_OBJECT_PARAGRAPH) },
114 { "as", ACTION(TEXT_OBJECT_SENTENCE) },
115 { "a<Tab>", ACTION(TEXT_OBJECT_INDENTATION) },
116 { "aW", ACTION(TEXT_OBJECT_LONGWORD_OUTER) },
117 { "aw", ACTION(TEXT_OBJECT_WORD_OUTER) },
118 { "gN", ACTION(TEXT_OBJECT_SEARCH_BACKWARD) },
119 { "gn", ACTION(TEXT_OBJECT_SEARCH_FORWARD) },
120 { "i<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_INNER) },
121 { "i`", ACTION(TEXT_OBJECT_BACKTICK_INNER) },
122 { "i{", ACTION(TEXT_OBJECT_CURLY_BRACKET_INNER) },
123 { "i(", ACTION(TEXT_OBJECT_PARANTHESE_INNER) },
124 { "i\"", ACTION(TEXT_OBJECT_QUOTE_INNER) },
125 { "i\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_INNER) },
126 { "i[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_INNER) },
127 { "i>", ALIAS("i<") },
128 { "i)", ALIAS("i(") },
129 { "i]", ALIAS("i[") },
130 { "i}", ALIAS("i{") },
131 { "ib", ALIAS("i(") },
132 { "iB", ALIAS("i{") },
133 { "ie", ACTION(TEXT_OBJECT_ENTIRE_INNER) },
134 { "il", ACTION(TEXT_OBJECT_LINE_INNER) },
135 { "ip", ACTION(TEXT_OBJECT_PARAGRAPH) },
136 { "is", ACTION(TEXT_OBJECT_SENTENCE) },
137 { "i<Tab>", ACTION(TEXT_OBJECT_INDENTATION) },
138 { "iW", ACTION(TEXT_OBJECT_LONGWORD_INNER) },
139 { "iw", ACTION(TEXT_OBJECT_WORD_INNER) },
140 { 0 /* empty last element, array terminator */ },
143 static const KeyBinding bindings_operators[] = {
144 { "0", ACTION(COUNT) },
145 { "1", ACTION(COUNT) },
146 { "2", ACTION(COUNT) },
147 { "3", ACTION(COUNT) },
148 { "4", ACTION(COUNT) },
149 { "5", ACTION(COUNT) },
150 { "6", ACTION(COUNT) },
151 { "7", ACTION(COUNT) },
152 { "8", ACTION(COUNT) },
153 { "9", ACTION(COUNT) },
154 { "~", ACTION(OPERATOR_CASE_SWAP) },
155 { "!", ACTION(OPERATOR_FILTER) },
156 { "=", ALIAS("gq") },
157 { "<", ACTION(OPERATOR_SHIFT_LEFT) },
158 { ">", ACTION(OPERATOR_SHIFT_RIGHT) },
159 { "\"", ACTION(REGISTER) },
160 { "c", ACTION(OPERATOR_CHANGE) },
161 { "d", ACTION(OPERATOR_DELETE) },
162 { "g~", ACTION(OPERATOR_CASE_SWAP) },
163 { "gp", ACTION(PUT_AFTER_END) },
164 { "gP", ACTION(PUT_BEFORE_END) },
165 { "gq", ACTION(OPERATOR_FILTER_FMT) },
166 { "gu", ACTION(OPERATOR_CASE_LOWER) },
167 { "gU", ACTION(OPERATOR_CASE_UPPER) },
168 { "p", ACTION(PUT_AFTER) },
169 { "P", ACTION(PUT_BEFORE) },
170 { "y", ACTION(OPERATOR_YANK) },
171 { 0 /* empty last element, array terminator */ },
174 static const KeyBinding bindings_operator_options[] = {
175 { "v", ACTION(MOTION_CHARWISE) },
176 { "V", ACTION(MOTION_LINEWISE) },
177 { 0 /* empty last element, array terminator */ },
180 static const KeyBinding bindings_normal[] = {
181 { "a", ACTION(APPEND_CHAR_NEXT) },
182 { "A", ACTION(APPEND_LINE_END) },
183 { "@", ACTION(MACRO_REPLAY) },
184 { ":", ACTION(PROMPT_SHOW) },
185 { ".", ACTION(REPEAT) },
186 { "~", ALIAS("<vis-operator-case-swap>ll") },
187 { "C", ALIAS("c$") },
188 { "<C-b>", ALIAS("<PageUp>") },
189 { "<C-c>", ACTION(CURSORS_REMOVE_COLUMN) },
190 { "<C-d>", ACTION(CURSORS_NEXT) },
191 { "<C-e>", ACTION(WINDOW_SLIDE_UP) },
192 { "<C-f>", ALIAS("<PageDown>") },
193 { "<C-i>", ACTION(JUMPLIST_NEXT) },
194 { "<C-j>", ACTION(CURSORS_NEW_LINE_BELOW) },
195 { "<C-k>", ACTION(CURSORS_NEW_LINE_ABOVE) },
196 { "<C-l>", ACTION(CURSORS_REMOVE_COLUMN_EXCEPT) },
197 { "<C-n>", ACTION(CURSOR_SELECT_WORD) },
198 { "<C-o>", ACTION(JUMPLIST_PREV) },
199 { "<C-p>", ACTION(CURSORS_REMOVE_LAST) },
200 { "<C-r>", ACTION(REDO) },
201 { "<C-u>", ACTION(CURSORS_PREV) },
202 { "<C-w><Backspace>", ALIAS("<C-w>k") },
203 { "<C-w>c", ALIAS(":q<Enter>") },
204 { "<C-w><C-h>", ALIAS("<C-w>k") },
205 { "<C-w><C-j>", ALIAS("<C-w>j") },
206 { "<C-w><C-k>", ALIAS("<C-w>k") },
207 { "<C-w><C-l>", ALIAS("<C-w>j") },
208 { "<C-w><C-w>", ALIAS("<C-w>j") },
209 { "<C-w>h", ALIAS("<C-w>k") },
210 { "<C-w>j", ACTION(WINDOW_NEXT) },
211 { "<C-w>k", ACTION(WINDOW_PREV) },
212 { "<C-w>l", ALIAS("<C-w>j") },
213 { "<C-w>n", ALIAS(":open<Enter>") },
214 { "<C-w>s", ALIAS(":split<Enter>") },
215 { "<C-w>v", ALIAS(":vsplit<Enter>") },
216 { "<C-w>w", ALIAS("<C-w>j") },
217 { "<C-y>", ACTION(WINDOW_SLIDE_DOWN) },
218 { "D", ALIAS("d$") },
219 { "<Delete>", ALIAS("x") },
220 { "<Escape>", ACTION(CURSORS_REMOVE_ALL) },
221 { "<F1>", ALIAS(":help<Enter>") },
222 { "ga", ACTION(UNICODE_INFO) },
223 { "g8", ACTION(UTF8_INFO) },
224 { "g,", ACTION(CHANGELIST_NEXT) },
225 { "g;", ACTION(CHANGELIST_PREV) },
226 { "g-", ACTION(EARLIER) },
227 { "g+", ACTION(LATER) },
228 { "gn", ALIAS("vgn") },
229 { "gN", ALIAS("vgN") },
230 { "gv", ACTION(SELECTION_RESTORE) },
231 { "I", ACTION(INSERT_LINE_START) },
232 { "i", ACTION(MODE_INSERT) },
233 { "J", ACTION(JOIN_LINES) },
234 { "gJ", ACTION(JOIN_LINES_TRIM) },
235 { "m", ACTION(MARK_SET) },
236 { "<M-C-j>", ACTION(CURSORS_NEW_LINE_BELOW_LAST) },
237 { "<M-C-k>", ACTION(CURSORS_NEW_LINE_ABOVE_FIRST) },
238 { "O", ACTION(OPEN_LINE_ABOVE) },
239 { "o", ACTION(OPEN_LINE_BELOW) },
240 { "q", ACTION(MACRO_RECORD) },
241 { "R", ACTION(MODE_REPLACE) },
242 { "r", ACTION(REPLACE_CHAR) },
243 { "S", ALIAS("^c$") },
244 { "s", ALIAS("cl") },
245 { "<Tab>", ACTION(CURSORS_ALIGN) },
246 { "u", ACTION(UNDO) },
247 { "v", ACTION(MODE_VISUAL) },
248 { "V", ACTION(MODE_VISUAL_LINE) },
249 { "x", ACTION(DELETE_CHAR_NEXT) },
250 { "X", ALIAS("dh") },
251 { "Y", ALIAS("y$") },
252 { "zb", ACTION(WINDOW_REDRAW_BOTTOM) },
253 { "ZQ", ALIAS(":q!<Enter>") },
254 { "zt", ACTION(WINDOW_REDRAW_TOP) },
255 { "zz", ACTION(WINDOW_REDRAW_CENTER) },
256 { "ZZ", ALIAS(":wq<Enter>") },
257 { 0 /* empty last element, array terminator */ },
260 static const KeyBinding bindings_visual[] = {
261 { "A", ACTION(CURSORS_NEW_LINES_END) },
262 { "@", ACTION(MACRO_REPLAY) },
263 { ":", ACTION(PROMPT_SHOW) },
264 { "-", ACTION(SELECTIONS_ROTATE_LEFT) },
265 { "+", ACTION(SELECTIONS_ROTATE_RIGHT) },
266 { "\\", ACTION(SELECTIONS_TRIM) },
267 { "<", ALIAS("<vis-operator-shift-left>gv") },
268 { ">", ALIAS("<vis-operator-shift-right>gv") },
269 { "<Backspace>", ALIAS("d") },
270 { "<C-b>", ALIAS("<PageUp>") },
271 { "<C-c>", ACTION(CURSORS_REMOVE_COLUMN) },
272 { "<C-d>", ACTION(CURSORS_NEXT) },
273 { "<C-f>", ALIAS("<PageDown>") },
274 { "<C-h>", ALIAS("<Backspace>") },
275 { "<C-j>", ALIAS("<C-d>") },
276 { "<C-k>", ALIAS("<C-u>") },
277 { "<C-l>", ACTION(CURSORS_REMOVE_COLUMN_EXCEPT) },
278 { "<C-n>", ACTION(CURSORS_NEW_MATCH_NEXT) },
279 { "<C-p>", ACTION(CURSORS_REMOVE_LAST) },
280 { "<C-u>", ACTION(CURSORS_PREV) },
281 { "<C-x>", ACTION(CURSORS_NEW_MATCH_SKIP) },
282 { "<Delete>", ALIAS("<Backspace>") },
283 { "<Escape>", ACTION(MODE_NORMAL) },
284 { "I", ACTION(CURSORS_NEW_LINES_BEGIN) },
285 { "J", ACTION(JOIN_LINES) },
286 { "gJ", ACTION(JOIN_LINES_TRIM) },
287 { "o", ACTION(SELECTION_FLIP) },
288 { "q", ACTION(MACRO_RECORD) },
289 { "r", ACTION(REPLACE_CHAR) },
290 { "s", ALIAS("c") },
291 { "<S-Tab>", ACTION(CURSORS_ALIGN_INDENT_RIGHT) },
292 { "<Tab>", ACTION(CURSORS_ALIGN_INDENT_LEFT) },
293 { "V", ACTION(MODE_VISUAL_LINE) },
294 { "v", ALIAS("<Escape>") },
295 { "x", ALIAS("d") },
296 { 0 /* empty last element, array terminator */ },
299 static const KeyBinding bindings_visual_line[] = {
300 { "v", ACTION(MODE_VISUAL) },
301 { "V", ACTION(MODE_NORMAL) },
302 { 0 /* empty last element, array terminator */ },
305 static const KeyBinding bindings_readline[] = {
306 { "<Backspace>", ACTION(DELETE_CHAR_PREV) },
307 { "<C-c>", ALIAS("<Escape>") },
308 { "<C-d>", ACTION(DELETE_CHAR_NEXT) },
309 { "<C-h>", ALIAS("<Backspace>") },
310 { "<C-u>", ACTION(DELETE_LINE_BEGIN) },
311 { "<C-v>", ACTION(INSERT_VERBATIM) },
312 { "<C-w>", ACTION(DELETE_WORD_PREV) },
313 { "<Delete>", ACTION(DELETE_CHAR_NEXT) },
314 { "<Escape>", ACTION(MODE_NORMAL) },
315 { 0 /* empty last element, array terminator */ },
318 static const KeyBinding bindings_insert[] = {
319 { "<C-d>", ALIAS("<vis-operator-shift-left><vis-operator-shift-left>") },
320 { "<C-i>", ALIAS("<Tab>") },
321 { "<C-j>", ALIAS("<Enter>") },
322 { "<C-m>", ALIAS("<Enter>") },
323 { "<C-r>", ACTION(INSERT_REGISTER) },
324 { "<C-t>", ALIAS("<vis-operator-shift-right><vis-operator-shift-right>") },
325 { "<C-x><C-e>", ACTION(WINDOW_SLIDE_UP) },
326 { "<C-x><C-y>", ACTION(WINDOW_SLIDE_DOWN) },
327 { "<Enter>", ACTION(INSERT_NEWLINE) },
328 { "<Escape>", ACTION(MODE_NORMAL) },
329 { "<S-Tab>", ACTION(CURSORS_ALIGN_INDENT_LEFT) },
330 { "<Tab>", ACTION(INSERT_TAB) },
331 { 0 /* empty last element, array terminator */ },
334 static const KeyBinding bindings_replace[] = {
335 { 0 /* empty last element, array terminator */ },
338 /* For each mode we list a all key bindings, if a key is bound in more than
339 * one array the first definition is used and further ones are ignored. */
340 static const KeyBinding **default_bindings[] = {
341 [VIS_MODE_OPERATOR_PENDING] = (const KeyBinding*[]){
342 bindings_operator_options,
343 bindings_operators,
344 bindings_textobjects,
345 bindings_motions,
346 bindings_basic,
347 NULL,
349 [VIS_MODE_NORMAL] = (const KeyBinding*[]){
350 bindings_normal,
351 bindings_operators,
352 bindings_motions,
353 bindings_basic,
354 NULL,
356 [VIS_MODE_VISUAL] = (const KeyBinding*[]){
357 bindings_visual,
358 bindings_textobjects,
359 bindings_operators,
360 bindings_motions,
361 bindings_basic,
362 NULL,
364 [VIS_MODE_VISUAL_LINE] = (const KeyBinding*[]){
365 bindings_visual_line,
366 NULL,
368 [VIS_MODE_INSERT] = (const KeyBinding*[]){
369 bindings_insert,
370 bindings_readline,
371 bindings_basic,
372 NULL,
374 [VIS_MODE_REPLACE] = (const KeyBinding*[]){
375 bindings_replace,
376 NULL,