map: fix return value of map_delete
[vis.git] / config.def.h
blob73a019310d2eaef69ad46bbde856b855b519edfd
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 KeyBinding bindings_basic[] = {
7 { "<C-z>", ACTION(EDITOR_SUSPEND) },
8 { "<Left>", ACTION(CURSOR_CHAR_PREV) },
9 { "<S-Left>", ACTION(CURSOR_LONGWORD_START_PREV) },
10 { "<Right>", ACTION(CURSOR_CHAR_NEXT) },
11 { "<S-Right>", ACTION(CURSOR_LONGWORD_START_NEXT) },
12 { "<Up>", ACTION(CURSOR_LINE_UP) },
13 { "<Down>", ACTION(CURSOR_LINE_DOWN) },
14 { "<PageUp>", ACTION(WINDOW_PAGE_UP) },
15 { "<PageDown>", ACTION(WINDOW_PAGE_DOWN) },
16 { "<S-PageUp>", ACTION(WINDOW_HALFPAGE_UP) },
17 { "<S-PageDown>", ACTION(WINDOW_HALFPAGE_DOWN) },
18 { "<Home>", ACTION(CURSOR_LINE_BEGIN) },
19 { "<End>", ACTION(CURSOR_LINE_END) },
20 { 0 /* empty last element, array terminator */ },
23 static const KeyBinding bindings_motions[] = {
24 { "h", ACTION(CURSOR_CHAR_PREV) },
25 { "<Backspace>", ALIAS("h") },
26 { "<C-h>", ALIAS("<Backspace>") },
27 { "l", ACTION(CURSOR_CHAR_NEXT) },
28 { " ", ALIAS("l") },
29 { "k", ACTION(CURSOR_LINE_UP) },
30 { "C-p", ALIAS("k") },
31 { "j", ACTION(CURSOR_LINE_DOWN) },
32 { "<C-j>", ALIAS("j") },
33 { "<C-n>", ALIAS("j") },
34 { "<Enter>", ALIAS("j") },
35 { "gk", ACTION(CURSOR_SCREEN_LINE_UP) },
36 { "g<Up>", ALIAS("gk") },
37 { "gj", ACTION(CURSOR_SCREEN_LINE_DOWN) },
38 { "g<Down>", ALIAS("gj") },
39 { "^", ACTION(CURSOR_LINE_START) },
40 { "g_", ACTION(CURSOR_LINE_FINISH) },
41 { "$", ACTION(CURSOR_LINE_END) },
42 { "%", ACTION(CURSOR_BRACKET_MATCH) },
43 { "b", ACTION(CURSOR_WORD_START_PREV) },
44 { "B", ACTION(CURSOR_LONGWORD_START_PREV) },
45 { "w", ACTION(CURSOR_WORD_START_NEXT) },
46 { "W", ACTION(CURSOR_LONGWORD_START_NEXT) },
47 { "ge", ACTION(CURSOR_WORD_END_PREV) },
48 { "gE", ACTION(CURSOR_LONGWORD_END_PREV) },
49 { "e", ACTION(CURSOR_WORD_END_NEXT) },
50 { "E", ACTION(CURSOR_LONGWORD_END_NEXT) },
51 { "{", ACTION(CURSOR_PARAGRAPH_PREV) },
52 { "}", ACTION(CURSOR_PARAGRAPH_NEXT) },
53 { "(", ACTION(CURSOR_SENTENCE_PREV) },
54 { ")", ACTION(CURSOR_SENTENCE_NEXT) },
55 { "[[", ACTION(CURSOR_FUNCTION_START_PREV) },
56 { "[]", ACTION(CURSOR_FUNCTION_END_PREV) },
57 { "][", ACTION(CURSOR_FUNCTION_START_NEXT) },
58 { "]]", ACTION(CURSOR_FUNCTION_END_NEXT) },
59 { "gg", ACTION(CURSOR_LINE_FIRST) },
60 { "g0", ACTION(CURSOR_SCREEN_LINE_BEGIN) },
61 { "gm", ACTION(CURSOR_SCREEN_LINE_MIDDLE) },
62 { "g$", ACTION(CURSOR_SCREEN_LINE_END) },
63 { "G", ACTION(CURSOR_LINE_LAST) },
64 { "|", ACTION(CURSOR_COLUMN) },
65 { "n", ACTION(CURSOR_SEARCH_NEXT) },
66 { "N", ACTION(CURSOR_SEARCH_PREV) },
67 { "H", ACTION(CURSOR_WINDOW_LINE_TOP) },
68 { "M", ACTION(CURSOR_WINDOW_LINE_MIDDLE) },
69 { "L", ACTION(CURSOR_WINDOW_LINE_BOTTOM) },
70 { "*", ACTION(CURSOR_SEARCH_WORD_FORWARD) },
71 { "#", ACTION(CURSOR_SEARCH_WORD_BACKWARD) },
72 { "f", ACTION(TO_RIGHT) },
73 { "F", ACTION(TO_LEFT) },
74 { "t", ACTION(TILL_RIGHT) },
75 { "T", ACTION(TILL_LEFT) },
76 { ";", ACTION(TOTILL_REPEAT) },
77 { ",", ACTION(TOTILL_REVERSE) },
78 { "/", ACTION(PROMPT_SEARCH_FORWARD) },
79 { "?", ACTION(PROMPT_SEARCH_BACKWARD) },
80 { "`", ACTION(MARK_GOTO) },
81 { "'", ACTION(MARK_GOTO_LINE) },
82 { 0 /* empty last element, array terminator */ },
85 static const KeyBinding bindings_textobjects[] = {
86 { "aw", ACTION(TEXT_OBJECT_WORD_OUTER) },
87 { "aW", ACTION(TEXT_OBJECT_LONGWORD_OUTER) },
88 { "as", ACTION(TEXT_OBJECT_SENTENCE) },
89 { "ap", ACTION(TEXT_OBJECT_PARAGRAPH) },
90 { "a[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_OUTER) },
91 { "a]", ALIAS("a[") },
92 { "a(", ACTION(TEXT_OBJECT_PARANTHESE_OUTER) },
93 { "a)", ALIAS("a(") },
94 { "ab", ALIAS("a(") },
95 { "a<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_OUTER) },
96 { "a>", ALIAS("a<") },
97 { "a{", ACTION(TEXT_OBJECT_CURLY_BRACKET_OUTER) },
98 { "a}", ALIAS("a{") },
99 { "aB", ALIAS("a{") },
100 { "a\"", ACTION(TEXT_OBJECT_QUOTE_OUTER) },
101 { "a\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_OUTER) },
102 { "a`", ACTION(TEXT_OBJECT_BACKTICK_OUTER) },
103 { "ae", ACTION(TEXT_OBJECT_ENTIRE_OUTER) },
104 { "af", ACTION(TEXT_OBJECT_FUNCTION_OUTER) },
105 { "al", ACTION(TEXT_OBJECT_LINE_OUTER) },
106 { "iw", ACTION(TEXT_OBJECT_WORD_INNER) },
107 { "iW", ACTION(TEXT_OBJECT_LONGWORD_INNER) },
108 { "is", ACTION(TEXT_OBJECT_SENTENCE) },
109 { "ip", ACTION(TEXT_OBJECT_PARAGRAPH) },
110 { "i[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_INNER) },
111 { "i]", ALIAS("i[") },
112 { "i(", ACTION(TEXT_OBJECT_PARANTHESE_INNER) },
113 { "i)", ALIAS("i(") },
114 { "ib", ALIAS("ib") },
115 { "i<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_INNER) },
116 { "i>", ALIAS("i<") },
117 { "i{", ACTION(TEXT_OBJECT_CURLY_BRACKET_INNER) },
118 { "i}", ALIAS("i{") },
119 { "iB", ALIAS("i{") },
120 { "i\"", ACTION(TEXT_OBJECT_QUOTE_INNER) },
121 { "i\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_INNER) },
122 { "i`", ACTION(TEXT_OBJECT_BACKTICK_INNER) },
123 { "ie", ACTION(TEXT_OBJECT_ENTIRE_INNER) },
124 { "if", ACTION(TEXT_OBJECT_FUNCTION_INNER) },
125 { "il", ACTION(TEXT_OBJECT_LINE_INNER) },
126 { 0 /* empty last element, array terminator */ },
129 static const KeyBinding bindings_operators[] = {
130 { "0", ACTION(COUNT) },
131 { "1", ACTION(COUNT) },
132 { "2", ACTION(COUNT) },
133 { "3", ACTION(COUNT) },
134 { "4", ACTION(COUNT) },
135 { "5", ACTION(COUNT) },
136 { "6", ACTION(COUNT) },
137 { "7", ACTION(COUNT) },
138 { "8", ACTION(COUNT) },
139 { "9", ACTION(COUNT) },
140 { "d", ACTION(OPERATOR_DELETE) },
141 { "c", ACTION(OPERATOR_CHANGE) },
142 { "y", ACTION(OPERATOR_YANK) },
143 { ">", ACTION(OPERATOR_SHIFT_RIGHT) },
144 { "<", ACTION(OPERATOR_SHIFT_LEFT) },
145 { "gU", ACTION(OPERATOR_CASE_UPPER) },
146 { "~", ACTION(OPERATOR_CASE_SWAP) },
147 { "g~", ACTION(OPERATOR_CASE_SWAP) },
148 { "gu", ACTION(OPERATOR_CASE_LOWER) },
149 { "!", ACTION(OPERATOR_FILTER) },
150 { "=", ACTION(OPERATOR_FILTER_FMT) },
151 { "\"", ACTION(REGISTER) },
152 { 0 /* empty last element, array terminator */ },
155 static const KeyBinding bindings_operator_options[] = {
156 { "v", ACTION(MOTION_CHARWISE) },
157 { "V", ACTION(MOTION_LINEWISE) },
158 { 0 /* empty last element, array terminator */ },
161 static const KeyBinding bindings_normal[] = {
162 { "<Escape>", ACTION(CURSORS_REMOVE_ALL) },
163 { "<Delete>", ALIAS("x") },
164 { "<C-k>", ACTION(CURSORS_NEW_LINE_ABOVE) },
165 { "<C-j>", ACTION(CURSORS_NEW_LINE_BELOW) },
166 { "<C-a>", ACTION(CURSORS_ALIGN) },
167 { "<C-n>", ACTION(CURSOR_SELECT_WORD) },
168 { "<C-p>", ACTION(CURSORS_REMOVE_LAST) },
169 { "<C-w>n", ALIAS(":open<Enter>") },
170 { "<C-w>c", ALIAS(":q<Enter>") },
171 { "<C-w>s", ALIAS(":split<Enter>") },
172 { "<C-w>v", ALIAS(":vsplit<Enter>") },
173 { "<C-w>j", ACTION(WINDOW_NEXT) },
174 { "<C-w>l", ALIAS("<C-w>j") },
175 { "<C-w>w", ALIAS("<C-w>j") },
176 { "<C-w><C-w>", ALIAS("<C-w>j") },
177 { "<C-w><C-j>", ALIAS("<C-w>j") },
178 { "<C-w><C-l>", ALIAS("<C-w>j") },
179 { "<C-w>k", ACTION(WINDOW_PREV) },
180 { "<C-w>h", ALIAS("<C-w>k") },
181 { "<C-w><C-h>", ALIAS("<C-w>k") },
182 { "<C-w><C-k>", ALIAS("<C-w>k") },
183 { "<C-w><Backspace>", ALIAS("<C-w>k") },
184 { "<C-b>", ALIAS("<PageUp>") },
185 { "<C-f>", ALIAS("<PageDown>") },
186 { "<C-u>", ALIAS("<S-PageUp>") },
187 { "<C-d>", ALIAS("<S-PageDown>") },
188 { "<C-e>", ACTION(WINDOW_SLIDE_UP) },
189 { "<C-y>", ACTION(WINDOW_SLIDE_DOWN) },
190 { "<C-o>", ACTION(JUMPLIST_PREV) },
191 { "<C-i>", ACTION(JUMPLIST_NEXT) },
192 { "g;", ACTION(CHANGELIST_PREV) },
193 { "g,", ACTION(CHANGELIST_NEXT) },
194 { "a", ACTION(APPEND_CHAR_NEXT) },
195 { "A", ACTION(APPEND_LINE_END) },
196 { "C", ALIAS("c$") },
197 { "D", ALIAS("d$") },
198 { "I", ACTION(INSERT_LINE_START) },
199 { ".", ACTION(REPEAT) },
200 { "o", ACTION(OPEN_LINE_BELOW) },
201 { "O", ACTION(OPEN_LINE_ABOVE) },
202 { "J", ACTION(JOIN_LINE_BELOW) },
203 { "x", ACTION(DELETE_CHAR_NEXT) },
204 { "r", ACTION(REPLACE_CHAR) },
205 { "i", ACTION(MODE_INSERT) },
206 { "v", ACTION(MODE_VISUAL) },
207 { "V", ACTION(MODE_VISUAL_LINE) },
208 { "R", ACTION(MODE_REPLACE) },
209 { "S", ALIAS("^c$") },
210 { "s", ALIAS("cl") },
211 { "Y", ALIAS("yy") },
212 { "X", ALIAS("dh") },
213 { "u", ACTION(UNDO) },
214 { "<C-r>", ACTION(REDO) },
215 { "g+", ACTION(LATER) },
216 { "g-", ACTION(EARLIER) },
217 { "<C-l>", ACTION(REDRAW) },
218 { ":", ACTION(PROMPT_SHOW) },
219 { "ZZ", ALIAS(":wq<Enter>") },
220 { "ZQ", ALIAS(":q!<Enter>") },
221 { "zt", ACTION(WINDOW_REDRAW_TOP) },
222 { "zz", ACTION(WINDOW_REDRAW_CENTER) },
223 { "zb", ACTION(WINDOW_REDRAW_BOTTOM) },
224 { "q", ACTION(MACRO_RECORD) },
225 { "@", ACTION(MACRO_REPLAY) },
226 { "gv", ACTION(SELECTION_RESTORE) },
227 { "m", ACTION(MARK_SET) },
228 { "<F1>", ALIAS(":help<Enter>") },
229 { "ga", ACTION(UNICODE_INFO) },
230 { "p", ACTION(PUT_AFTER) },
231 { "P", ACTION(PUT_BEFORE) },
232 { "gp", ACTION(PUT_AFTER_END) },
233 { "gP", ACTION(PUT_BEFORE_END) },
234 { 0 /* empty last element, array terminator */ },
237 static const KeyBinding bindings_visual[] = {
238 { "<C-n>", ACTION(CURSORS_NEW_MATCH_NEXT) },
239 { "<C-x>", ACTION(CURSORS_NEW_MATCH_SKIP) },
240 { "<C-p>", ACTION(CURSORS_REMOVE_LAST) },
241 { "I", ACTION(CURSORS_NEW_LINES_BEGIN) },
242 { "A", ACTION(CURSORS_NEW_LINES_END) },
243 { "<Backspace>", ALIAS("d") },
244 { "<C-h>", ALIAS("<Backspace>") },
245 { "<Delete>", ALIAS("<Backspace>") },
246 { "<Escape>", ACTION(MODE_NORMAL) },
247 { "<C-c>", ALIAS("<Escape>") },
248 { "v", ALIAS("<Escape>") },
249 { "V", ACTION(MODE_VISUAL_LINE) },
250 { ":", ACTION(PROMPT_SHOW_VISUAL) },
251 { "x", ALIAS("d") },
252 { "r", ALIAS("c") },
253 { "s", ALIAS("c") },
254 { "J", ACTION(JOIN_LINES) },
255 { "o", ACTION(SELECTION_FLIP) },
256 { 0 /* empty last element, array terminator */ },
259 static const KeyBinding bindings_visual_line[] = {
260 { "v", ACTION(MODE_VISUAL) },
261 { "V", ACTION(MODE_NORMAL) },
262 { 0 /* empty last element, array terminator */ },
265 static const KeyBinding bindings_readline[] = {
266 { "<Backspace>", ACTION(DELETE_CHAR_PREV) },
267 { "<C-h>", ALIAS("<Backspace>") },
268 { "<Delete>", ACTION(DELETE_CHAR_NEXT) },
269 { "<Escape>", ACTION(MODE_NORMAL) },
270 { "<C-c>", ALIAS("<Enter>") },
271 { "<C-d>", ACTION(DELETE_CHAR_NEXT) },
272 { "<C-w>", ACTION(DELETE_WORD_PREV) },
273 { "<C-u>", ACTION(DELETE_LINE_BEGIN) },
274 { "<C-v>", ACTION(INSERT_VERBATIM) },
275 { 0 /* empty last element, array terminator */ },
278 static const KeyBinding bindings_prompt[] = {
279 { "<Backspace>", ACTION(PROMPT_BACKSPACE) },
280 { "<C-h>", ALIAS("<Backspace>") },
281 { "<Enter>", ACTION(PROMPT_ENTER) },
282 { "<C-j>", ALIAS("<Enter>") },
283 { "<Tab>", ACTION(NOP) },
284 { 0 /* empty last element, array terminator */ },
287 static const KeyBinding bindings_insert[] = {
288 { "<Escape>", ACTION(MODE_NORMAL) },
289 { "<C-c>", ALIAS("<Escape>") },
290 { "<C-i>", ALIAS("<Tab>") },
291 { "<Enter>", ACTION(INSERT_NEWLINE) },
292 { "<C-j>", ALIAS("<Enter>") },
293 { "<C-m>", ALIAS("<Enter>") },
294 { "<C-o>", ACTION(MODE_OPERATOR_PENDING) },
295 { "<C-d>", ALIAS("<Escape><<i") },
296 { "<C-t>", ALIAS("<Escape>>>i") },
297 { "<C-x><C-e>", ACTION(WINDOW_SLIDE_UP) },
298 { "<C-x><C-y>", ACTION(WINDOW_SLIDE_DOWN) },
299 { "<Tab>", ACTION(INSERT_TAB) },
300 { "<C-r>", ACTION(INSERT_REGISTER) },
301 { 0 /* empty last element, array terminator */ },
304 static const KeyBinding bindings_replace[] = {
305 { 0 /* empty last element, array terminator */ },
308 /* For each mode we list a all key bindings, if a key is bound in more than
309 * one array the first definition is used and further ones are ignored. */
310 static const KeyBinding **default_bindings[] = {
311 [VIS_MODE_OPERATOR_PENDING] = (const KeyBinding*[]){
312 bindings_operator_options,
313 bindings_operators,
314 bindings_textobjects,
315 bindings_motions,
316 bindings_basic,
317 NULL,
319 [VIS_MODE_NORMAL] = (const KeyBinding*[]){
320 bindings_normal,
321 bindings_operators,
322 bindings_motions,
323 bindings_basic,
324 NULL,
326 [VIS_MODE_VISUAL] = (const KeyBinding*[]){
327 bindings_visual,
328 bindings_textobjects,
329 bindings_operators,
330 bindings_motions,
331 bindings_basic,
332 NULL,
334 [VIS_MODE_VISUAL_LINE] = (const KeyBinding*[]){
335 bindings_visual_line,
336 bindings_visual,
337 bindings_textobjects,
338 bindings_operators,
339 bindings_motions,
340 bindings_basic,
341 NULL,
343 [VIS_MODE_INSERT] = (const KeyBinding*[]){
344 bindings_insert,
345 bindings_readline,
346 bindings_basic,
347 NULL,
349 [VIS_MODE_REPLACE] = (const KeyBinding*[]){
350 bindings_replace,
351 bindings_insert,
352 bindings_readline,
353 bindings_basic,
354 NULL,
356 [VIS_MODE_PROMPT] = (const KeyBinding*[]){
357 bindings_prompt,
358 bindings_readline,
359 bindings_basic,
360 NULL,