Add explicit build commands to README
[vis.git] / config.def.h
blobb8b9dd5b63e3f956b9db2c65100d29317faba073
1 /* Configure your desired default key bindings.
3 * Vis stores modes in a tree structure. Key lookup starts in the currently active
4 * mode and continues recursively towards the root of the tree until a match is found.
5 * This reduces duplication since shared key bindings can be stored in a common
6 * ancestor mode.
8 * The tree of modes is depicted below. The double line between OPERATOR-OPTION
9 * and OPERATOR is only in effect once an operator is detected. That is when
10 * entering the OPERATOR mode its parent is set to OPERATOR-OPTION which makes
11 * TEXTOBJ reachable. Once the operator is processed (i.e. OPERATOR mode is left)
12 * its parent mode is reset back to MOVE.
14 * Similarly the +-ed line between OPERATOR and TEXTOBJ is only active within
15 * the visual modes.
17 * BASIC
18 * (arrow keys etc.)
19 * / |
20 * /-------------------/ |
21 * READLINE MOVE
22 * / \ (h,j,k,l ...)
23 * / \ | \-----------------\
24 * / \ | |
25 * INSERT PROMPT OPERATOR ++++ -TEXTOBJ
26 * | (history etc) (d,c,y,p ..) + (ia [wsp[]()b<>{}B"'`] )
27 * | | \\ + + |
28 * | | \\ + + |
29 * REPLACE NORMAL \\ + + |
30 * | \\ ++ |
31 * | \\ |
32 * | \\ |
33 * VISUAL \\ OPERATOR-OPTION
34 * | \\ (v,V)
35 * | \\ //
36 * | \\======//
37 * VISUAL-LINE
40 #define ALIAS(name) .alias = name,
41 #define ACTION(id) .action = &vis_action[VIS_ACTION_##id],
43 static KeyBinding basic_movement[] = {
44 { "<C-z>", ACTION(EDITOR_SUSPEND) },
45 { "<Left>", ACTION(CURSOR_CHAR_PREV) },
46 { "<S-Left>", ACTION(CURSOR_LONGWORD_START_PREV) },
47 { "<Right>", ACTION(CURSOR_CHAR_NEXT) },
48 { "<S-Right>", ACTION(CURSOR_LONGWORD_START_NEXT) },
49 { "<Up>", ACTION(CURSOR_LINE_UP) },
50 { "<Down>", ACTION(CURSOR_LINE_DOWN) },
51 { "<PageUp>", ACTION(WINDOW_PAGE_UP) },
52 { "<PageDown>", ACTION(WINDOW_PAGE_DOWN) },
53 { "<S-PageUp>", ACTION(WINDOW_HALFPAGE_UP) },
54 { "<S-PageDown>", ACTION(WINDOW_HALFPAGE_DOWN) },
55 { "<Home>", ACTION(CURSOR_LINE_BEGIN) },
56 { "<End>", ACTION(CURSOR_LINE_END) },
57 { /* empty last element, array terminator */ },
60 static KeyBinding vis_movements[] = {
61 { "h", ACTION(CURSOR_CHAR_PREV) },
62 { "<Backspace>", ALIAS("h") },
63 { "<C-h>", ALIAS("<Backspace>") },
64 { "l", ACTION(CURSOR_CHAR_NEXT) },
65 { " ", ALIAS("l") },
66 { "k", ACTION(CURSOR_LINE_UP) },
67 { "C-p", ALIAS("k") },
68 { "j", ACTION(CURSOR_LINE_DOWN) },
69 { "<C-j>", ALIAS("j") },
70 { "<C-n>", ALIAS("j") },
71 { "<Enter>", ALIAS("j") },
72 { "gk", ACTION(CURSOR_SCREEN_LINE_UP) },
73 { "g<Up>", ALIAS("gk") },
74 { "gj", ACTION(CURSOR_SCREEN_LINE_DOWN) },
75 { "g<Down>", ALIAS("gj") },
76 { "^", ACTION(CURSOR_LINE_START) },
77 { "g_", ACTION(CURSOR_LINE_FINISH) },
78 { "$", ACTION(CURSOR_LINE_END) },
79 { "%", ACTION(CURSOR_BRACKET_MATCH) },
80 { "b", ACTION(CURSOR_WORD_START_PREV) },
81 { "B", ACTION(CURSOR_LONGWORD_START_PREV) },
82 { "w", ACTION(CURSOR_WORD_START_NEXT) },
83 { "W", ACTION(CURSOR_LONGWORD_START_NEXT) },
84 { "ge", ACTION(CURSOR_WORD_END_PREV) },
85 { "gE", ACTION(CURSOR_LONGWORD_END_PREV) },
86 { "e", ACTION(CURSOR_WORD_END_NEXT) },
87 { "E", ACTION(CURSOR_LONGWORD_END_NEXT) },
88 { "{", ACTION(CURSOR_PARAGRAPH_PREV) },
89 { "}", ACTION(CURSOR_PARAGRAPH_NEXT) },
90 { "(", ACTION(CURSOR_SENTENCE_PREV) },
91 { ")", ACTION(CURSOR_SENTENCE_NEXT) },
92 { "[[", ACTION(CURSOR_FUNCTION_START_PREV) },
93 { "[]", ACTION(CURSOR_FUNCTION_END_PREV) },
94 { "][", ACTION(CURSOR_FUNCTION_START_NEXT) },
95 { "]]", ACTION(CURSOR_FUNCTION_END_NEXT) },
96 { "gg", ACTION(CURSOR_LINE_FIRST) },
97 { "g0", ACTION(CURSOR_SCREEN_LINE_BEGIN) },
98 { "gm", ACTION(CURSOR_SCREEN_LINE_MIDDLE) },
99 { "g$", ACTION(CURSOR_SCREEN_LINE_END) },
100 { "G", ACTION(CURSOR_LINE_LAST) },
101 { "|", ACTION(CURSOR_COLUMN) },
102 { "n", ACTION(CURSOR_SEARCH_NEXT) },
103 { "N", ACTION(CURSOR_SEARCH_PREV) },
104 { "H", ACTION(CURSOR_WINDOW_LINE_TOP) },
105 { "M", ACTION(CURSOR_WINDOW_LINE_MIDDLE) },
106 { "L", ACTION(CURSOR_WINDOW_LINE_BOTTOM) },
107 { "*", ACTION(CURSOR_SEARCH_WORD_FORWARD) },
108 { "#", ACTION(CURSOR_SEARCH_WORD_BACKWARD) },
109 { "f", ACTION(TO_RIGHT) },
110 { "F", ACTION(TO_LEFT) },
111 { "t", ACTION(TILL_RIGHT) },
112 { "T", ACTION(TILL_LEFT) },
113 { ";", ACTION(TOTILL_REPEAT) },
114 { ",", ACTION(TOTILL_REVERSE) },
115 { "/", ACTION(PROMPT_SEARCH_FORWARD) },
116 { "?", ACTION(PROMPT_SEARCH_BACKWARD) },
117 { "`", ACTION(MARK_GOTO) },
118 { "'", ACTION(MARK_GOTO_LINE) },
119 { /* empty last element, array terminator */ },
122 static KeyBinding vis_textobjs[] = {
123 { "aw", ACTION(TEXT_OBJECT_WORD_OUTER) },
124 { "aW", ACTION(TEXT_OBJECT_LONGWORD_OUTER) },
125 { "as", ACTION(TEXT_OBJECT_SENTENCE) },
126 { "ap", ACTION(TEXT_OBJECT_PARAGRAPH) },
127 { "a[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_OUTER) },
128 { "a]", ALIAS("a[") },
129 { "a(", ACTION(TEXT_OBJECT_PARANTHESE_OUTER) },
130 { "a)", ALIAS("a(") },
131 { "ab", ALIAS("a(") },
132 { "a<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_OUTER) },
133 { "a>", ALIAS("a<") },
134 { "a{", ACTION(TEXT_OBJECT_CURLY_BRACKET_OUTER) },
135 { "a}", ALIAS("a{") },
136 { "aB", ALIAS("a{") },
137 { "a\"", ACTION(TEXT_OBJECT_QUOTE_OUTER) },
138 { "a\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_OUTER) },
139 { "a`", ACTION(TEXT_OBJECT_BACKTICK_OUTER) },
140 { "ae", ACTION(TEXT_OBJECT_ENTIRE_OUTER) },
141 { "af", ACTION(TEXT_OBJECT_FUNCTION_OUTER) },
142 { "al", ACTION(TEXT_OBJECT_LINE_OUTER) },
143 { "iw", ACTION(TEXT_OBJECT_WORD_INNER) },
144 { "iW", ACTION(TEXT_OBJECT_LONGWORD_INNER) },
145 { "is", ACTION(TEXT_OBJECT_SENTENCE) },
146 { "ip", ACTION(TEXT_OBJECT_PARAGRAPH) },
147 { "i[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_INNER) },
148 { "i]", ALIAS("i[") },
149 { "i(", ACTION(TEXT_OBJECT_PARANTHESE_INNER) },
150 { "i)", ALIAS("i(") },
151 { "ib", ALIAS("ib") },
152 { "i<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_INNER) },
153 { "i>", ALIAS("i<") },
154 { "i{", ACTION(TEXT_OBJECT_CURLY_BRACKET_INNER) },
155 { "i}", ALIAS("i{") },
156 { "iB", ALIAS("i{") },
157 { "i\"", ACTION(TEXT_OBJECT_QUOTE_INNER) },
158 { "i\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_INNER) },
159 { "i`", ACTION(TEXT_OBJECT_BACKTICK_INNER) },
160 { "ie", ACTION(TEXT_OBJECT_ENTIRE_INNER) },
161 { "if", ACTION(TEXT_OBJECT_FUNCTION_INNER) },
162 { "il", ACTION(TEXT_OBJECT_LINE_INNER) },
163 { /* empty last element, array terminator */ },
166 static KeyBinding vis_operators[] = {
167 { "0", ACTION(COUNT) },
168 { "1", ACTION(COUNT) },
169 { "2", ACTION(COUNT) },
170 { "3", ACTION(COUNT) },
171 { "4", ACTION(COUNT) },
172 { "5", ACTION(COUNT) },
173 { "6", ACTION(COUNT) },
174 { "7", ACTION(COUNT) },
175 { "8", ACTION(COUNT) },
176 { "9", ACTION(COUNT) },
177 { "d", ACTION(OPERATOR_DELETE) },
178 { "c", ACTION(OPERATOR_CHANGE) },
179 { "y", ACTION(OPERATOR_YANK) },
180 { "p", ACTION(PUT_AFTER) },
181 { "P", ACTION(PUT_BEFORE) },
182 { "gp", ACTION(PUT_AFTER_END) },
183 { "gP", ACTION(PUT_BEFORE_END) },
184 { ">", ACTION(OPERATOR_SHIFT_RIGHT) },
185 { "<", ACTION(OPERATOR_SHIFT_LEFT) },
186 { "gU", ACTION(OPERATOR_CASE_UPPER) },
187 { "~", ACTION(OPERATOR_CASE_SWAP) },
188 { "g~", ACTION(OPERATOR_CASE_SWAP) },
189 { "gu", ACTION(OPERATOR_CASE_LOWER) },
190 { "!", ACTION(OPERATOR_FILTER) },
191 { "=", ACTION(OPERATOR_FILTER_FMT) },
192 { "\"", ACTION(REGISTER) },
193 { /* empty last element, array terminator */ },
196 static KeyBinding vis_operator_options[] = {
197 { "v", ACTION(MOTION_CHARWISE) },
198 { "V", ACTION(MOTION_LINEWISE) },
199 { /* empty last element, array terminator */ },
202 static KeyBinding vis_mode_normal[] = {
203 { "<Escape>", ACTION(CURSORS_REMOVE_ALL) },
204 { "<Delete>", ALIAS("x") },
205 { "<C-k>", ACTION(CURSORS_NEW_LINE_ABOVE) },
206 { "<C-j>", ACTION(CURSORS_NEW_LINE_BELOW) },
207 { "<C-a>", ACTION(CURSORS_ALIGN) },
208 { "<C-n>", ACTION(CURSOR_SELECT_WORD) },
209 { "<C-p>", ACTION(CURSORS_REMOVE_LAST) },
210 { "<C-w>n", ALIAS(":open<Enter>") },
211 { "<C-w>c", ALIAS(":q<Enter>") },
212 { "<C-w>s", ALIAS(":split<Enter>") },
213 { "<C-w>v", ALIAS(":vsplit<Enter>") },
214 { "<C-w>j", ACTION(WINDOW_NEXT) },
215 { "<C-w>l", ALIAS("<C-w>j") },
216 { "<C-w>w", ALIAS("<C-w>j") },
217 { "<C-w><C-w>", ALIAS("<C-w>j") },
218 { "<C-w><C-j>", ALIAS("<C-w>j") },
219 { "<C-w><C-l>", ALIAS("<C-w>j") },
220 { "<C-w>k", ACTION(WINDOW_PREV) },
221 { "<C-w>h", ALIAS("<C-w>k") },
222 { "<C-w><C-h>", ALIAS("<C-w>k") },
223 { "<C-w><C-k>", ALIAS("<C-w>k") },
224 { "<C-w><Backspace>", ALIAS("<C-w>k") },
225 { "<C-b>", ALIAS("<PageUp>") },
226 { "<C-f>", ALIAS("<PageDown>") },
227 { "<C-u>", ALIAS("<S-PageUp>") },
228 { "<C-d>", ALIAS("<S-PageDown>") },
229 { "<C-e>", ACTION(WINDOW_SLIDE_UP) },
230 { "<C-y>", ACTION(WINDOW_SLIDE_DOWN) },
231 { "<C-o>", ACTION(JUMPLIST_PREV) },
232 { "<C-i>", ACTION(JUMPLIST_NEXT) },
233 { "g;", ACTION(CHANGELIST_PREV) },
234 { "g,", ACTION(CHANGELIST_NEXT) },
235 { "a", ACTION(APPEND_CHAR_NEXT) },
236 { "A", ACTION(APPEND_LINE_END) },
237 { "C", ALIAS("c$") },
238 { "D", ALIAS("d$") },
239 { "I", ACTION(INSERT_LINE_START) },
240 { ".", ACTION(REPEAT) },
241 { "o", ACTION(OPEN_LINE_BELOW) },
242 { "O", ACTION(OPEN_LINE_ABOVE) },
243 { "J", ACTION(JOIN_LINE_BELOW) },
244 { "x", ACTION(DELETE_CHAR_NEXT) },
245 { "r", ACTION(REPLACE_CHAR) },
246 { "i", ACTION(MODE_INSERT) },
247 { "v", ACTION(MODE_VISUAL) },
248 { "V", ACTION(MODE_VISUAL_LINE) },
249 { "R", ACTION(MODE_REPLACE) },
250 { "S", ALIAS("^c$") },
251 { "s", ALIAS("cl") },
252 { "Y", ALIAS("yy") },
253 { "X", ALIAS("dh") },
254 { "u", ACTION(UNDO) },
255 { "<C-r>", ACTION(REDO) },
256 { "g+", ACTION(LATER) },
257 { "g-", ACTION(EARLIER) },
258 { "<C-l>", ACTION(REDRAW) },
259 { ":", ACTION(PROMPT_SHOW) },
260 { "ZZ", ALIAS(":wq<Enter>") },
261 { "ZQ", ALIAS(":q!<Enter>") },
262 { "zt", ACTION(WINDOW_REDRAW_TOP) },
263 { "zz", ACTION(WINDOW_REDRAW_CENTER) },
264 { "zb", ACTION(WINDOW_REDRAW_BOTTOM) },
265 { "q", ACTION(MACRO_RECORD) },
266 { "@", ACTION(MACRO_REPLAY) },
267 { "gv", ACTION(SELECTION_RESTORE) },
268 { "m", ACTION(MARK_SET) },
269 { "<F1>", ALIAS(":help<Enter>") },
270 { "ga", ACTION(UNICODE_INFO) },
271 { /* empty last element, array terminator */ },
274 static KeyBinding vis_mode_visual[] = {
275 { "<C-n>", ACTION(CURSORS_NEW_MATCH_NEXT) },
276 { "<C-x>", ACTION(CURSORS_NEW_MATCH_SKIP) },
277 { "<C-p>", ACTION(CURSORS_REMOVE_LAST) },
278 { "I", ACTION(CURSORS_NEW_LINES_BEGIN) },
279 { "A", ACTION(CURSORS_NEW_LINES_END) },
280 { "<Backspace>", ALIAS("d") },
281 { "<C-h>", ALIAS("<Backspace>") },
282 { "<Delete>", ALIAS("<Backspace>") },
283 { "<Escape>", ACTION(MODE_NORMAL) },
284 { "<C-c>", ALIAS("<Escape>") },
285 { "v", ALIAS("<Escape>") },
286 { "V", ACTION(MODE_VISUAL_LINE) },
287 { ":", ACTION(PROMPT_SHOW_VISUAL) },
288 { "x", ALIAS("d") },
289 { "r", ALIAS("c") },
290 { "s", ALIAS("c") },
291 { "J", ACTION(JOIN_LINES) },
292 { "o", ACTION(SELECTION_FLIP) },
293 { /* empty last element, array terminator */ },
296 static KeyBinding vis_mode_visual_line[] = {
297 { "v", ACTION(MODE_VISUAL) },
298 { "V", ACTION(MODE_NORMAL) },
299 { /* empty last element, array terminator */ },
302 static KeyBinding vis_mode_readline[] = {
303 { "<Backspace>", ACTION(DELETE_CHAR_PREV) },
304 { "<C-h>", ALIAS("<Backspace>") },
305 { "<Delete>", ACTION(DELETE_CHAR_NEXT) },
306 { "<Escape>", ACTION(MODE_NORMAL) },
307 { "<C-c>", ALIAS("<Enter>") },
308 { "<C-d>", ACTION(DELETE_CHAR_NEXT) },
309 { "<C-w>", ACTION(DELETE_WORD_PREV) },
310 { "<C-u>", ACTION(DELETE_LINE_BEGIN) },
311 { /* empty last element, array terminator */ },
314 static KeyBinding vis_mode_prompt[] = {
315 { "<Backspace>", ACTION(PROMPT_BACKSPACE) },
316 { "<C-h>", ALIAS("<Backspace>") },
317 { "<Enter>", ACTION(PROMPT_ENTER) },
318 { "<C-j>", ALIAS("<Enter>") },
319 { "<Tab>", ACTION(NOP) },
320 { /* empty last element, array terminator */ },
323 static KeyBinding vis_mode_insert[] = {
324 { "<Escape>", ACTION(MODE_NORMAL) },
325 { "<C-c>", ALIAS("<Escape>") },
326 { "<C-i>", ALIAS("<Tab>") },
327 { "<Enter>", ACTION(INSERT_NEWLINE) },
328 { "<C-j>", ALIAS("<Enter>") },
329 { "<C-m>", ALIAS("<Enter>") },
330 { "<C-o>", ACTION(MODE_OPERATOR_PENDING) },
331 { "<C-v>", ACTION(INSERT_VERBATIM) },
332 { "<C-d>", ALIAS("<Escape><<i") },
333 { "<C-t>", ALIAS("<Escape>>>i") },
334 { "<C-x><C-e>", ACTION(WINDOW_SLIDE_UP) },
335 { "<C-x><C-y>", ACTION(WINDOW_SLIDE_DOWN) },
336 { "<Tab>", ACTION(INSERT_TAB) },
337 { "<C-r>", ACTION(INSERT_REGISTER) },
338 { /* empty last element, array terminator */ },
341 static KeyBinding vis_mode_replace[] = {
342 { /* empty last element, array terminator */ },