2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
9 static char sccsid
[] = "$Id: v_cmd.c,v 8.22 1994/01/08 17:07:27 bostic Exp $ (Berkeley) $Date: 1994/01/08 17:07:27 $";
12 #include <sys/types.h>
18 * This array maps keystrokes to vi command functions. It is known
19 * in ex/ex_usage.c that it takes four columns to name a vi character.
21 VIKEYS
const vikeys
[MAXVIKEY
+ 1] = {
22 /* 000 NUL -- The code in vi.c expects key 0 to be undefined. */
25 {v_searchw
, V_ABS
|V_CNT
|V_MOVE
|V_KEYW
|V_RCM_SET
,
27 "^A search forward for cursor word"},
29 {v_pageup
, V_ABS
|V_CNT
|V_RCM_SETLFNB
,
31 "^B page up by screens"},
35 "^C interrupt a search or global command"},
37 {v_hpagedown
, V_ABS
|V_CNT
|V_RCM_SETLFNB
,
39 "^D page down by half screens (setting count)"},
43 "^E page down by lines"},
45 {v_pagedown
, V_ABS
|V_CNT
|V_RCM_SETLFNB
,
47 "^F page down by screens"},
53 {v_left
, V_CNT
|V_MOVE
|V_RCM_SET
,
55 "^H move left by columns"},
59 {v_down
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM
,
61 "^J move down by lines"},
69 {v_cr
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SETFNB
,
71 "^M move down by lines (to first non-blank)"},
73 {v_down
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM
,
75 "^N move down by lines"},
79 {v_up
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM
,
81 "^P move up by lines"},
82 /* 021 ^Q -- not available, used for hardware flow control. */
88 /* 023 ^S -- not available, used for hardware flow control. */
95 {v_hpageup
, V_ABS
|V_CNT
|V_RCM_SETLFNB
,
97 "^U half page up (set count)"},
101 "^V input a literal character"},
105 "^W move to next screen"},
111 "^Y page up by lines"},
115 "^Z suspend editor"},
119 "^[ <escape> leave input mode, return to command mode"},
123 {v_tagpush
, V_KEYW
|V_RCM_SET
,
125 "^] tag push cursor word"},
129 "^^ switch to previous file"},
133 {v_right
, V_CNT
|V_MOVE
|V_RCM_SET
,
135 " <space> move right by columns"},
137 {v_filter
, V_CNT
|V_DOT
|V_MOTION
|V_RCM_SET
,
138 "[count]![count]motion command(s)",
139 " ! filter through command(s) to motion"},
143 {v_increment
, V_CHAR
|V_CNT
|V_DOT
|V_KEYNUM
|V_RCM_SET
,
145 " # number increment/decrement"},
147 {v_dollar
, V_CNT
|V_MOVE
|V_RCM_SETLAST
,
149 " $ move to last column"},
151 {v_match
, V_ABS
|V_MOVE
|V_RCM_SET
,
157 " & repeat substitution"},
159 {v_gomark
, V_ABS
|V_CHAR
|V_LMODE
|V_MOVE
|V_RCM_SETFNB
,
161 " ' move to mark (to first non-blank)"},
163 {v_sentenceb
, V_CNT
|V_MOVE
|V_RCM_SET
,
165 " ( move back sentence"},
167 {v_sentencef
, V_ABS
|V_CNT
|V_MOVE
|V_RCM_SET
,
169 " ) move forward sentence"},
173 {v_down
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SETFNB
,
175 " + move down by lines (to first non-blank)"},
177 {v_chrrepeat
, V_CNT
|V_MOVE
|V_RCM_SET
,
179 " , reverse last F, f, T or t search"},
181 {v_up
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SETFNB
,
183 " - move up by lines (to first non-blank)"},
187 " . repeat the last command"},
189 {v_searchf
, V_ABS
|V_MOVE
|V_RCM_SET
,
191 " / search forward"},
193 {v_zero
, V_MOVE
|V_RCM_SET
,
195 " 0 move to first character"},
216 ":command [| command] ...",
219 {v_chrepeat
, V_CNT
|V_MOVE
|V_RCM_SET
,
221 " ; repeat last F, f, T or t search"},
223 {v_shiftl
, V_CNT
|V_DOT
|V_MOTION
|V_RCM_SET
|VC_SH
,
224 "[count]<[count]motion",
225 " < shift lines left to motion"},
229 {v_shiftr
, V_CNT
|V_DOT
|V_MOTION
|V_RCM_SET
|VC_SH
,
230 "[count]>[count]motion",
231 " > shift lines right to motion"},
233 {v_searchb
, V_ABS
|V_MOVE
|V_RCM_SET
,
235 " ? search backward"},
237 {v_at
, V_RBUF
|V_RCM_SET
,
239 " @ execute buffer"},
241 {v_iA
, V_CNT
|V_DOT
|V_RCM_SET
,
243 " A append to the line"},
245 {v_wordB
, V_CNT
|V_MOVE
|V_RCM_SET
,
247 " B move back bigword"},
249 {v_Change
, V_CNT
|V_DOT
|V_OBUF
|V_RCM_SET
,
251 " C change to end-of-line"},
253 {v_Delete
, V_CNT
|V_DOT
|V_OBUF
|V_RCM_SET
,
255 " D delete to end-of-line"},
257 {v_wordE
, V_CNT
|V_MOVE
|V_RCM_SET
,
259 " E move to end of bigword"},
261 {v_chF
, V_CHAR
|V_CNT
|V_MOVE
|V_RCM_SET
,
262 "[count]F character",
263 " F character in line backward search"},
265 {v_lgoto
, V_ABS
|V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SETFNB
,
269 {v_home
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SETNNB
,
271 " H move to count lines from screen top"},
273 {v_iI
, V_CNT
|V_DOT
|V_RCM_SET
,
275 " I insert at line beginning"},
277 {v_join
, V_CNT
|V_DOT
|V_RCM_SET
,
283 {v_bottom
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SETNNB
,
285 " L move to screen bottom"},
287 {v_middle
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SETNNB
,
289 " M move to screen middle"},
291 {v_searchN
, V_ABS
|V_MOVE
|V_RCM_SET
,
293 " N reverse last search"},
295 {v_iO
, V_CNT
|V_DOT
|V_RCM_SET
,
297 " O insert above line"},
299 {v_Put
, V_CNT
|V_DOT
|V_OBUF
|V_RCM_SET
,
301 " P insert before cursor from buffer"},
305 " Q switch to ex mode"},
307 {v_Replace
, V_CNT
|V_DOT
|V_RCM_SET
,
309 " R replace characters"},
311 {v_Subst
, V_CNT
|V_DOT
|V_LMODE
|V_OBUF
|V_RCM_SET
,
313 " S substitute for the line(s)"},
315 {v_chT
, V_CHAR
|V_CNT
|V_MOVE
|V_RCM_SET
,
316 "[count]T character",
317 " T before character in line backward search"},
321 " U Restore the current line"},
325 {v_wordW
, V_CNT
|V_MOVE
|V_RCM_SET
,
327 " W move to next bigword"},
329 {v_Xchar
, V_CNT
|V_DOT
|V_OBUF
|V_RCM_SET
,
331 " X delete character before cursor"},
333 {v_Yank
, V_CNT
|V_LMODE
|V_OBUF
,
339 "ZZ save file and exit"},
341 {v_sectionb
, V_ABS
|V_LMODE
|V_MOVE
|V_RCM_SET
,
343 "[[ move back section"},
347 {v_sectionf
, V_ABS
|V_LMODE
|V_MOVE
|V_RCM_SET
,
349 "]] move forward section"},
352 * DON'T set the V_RCM_SETFNB flag, the function has to do
353 * the work anyway, in case it's a motion component. DO set
354 * V_RCM_SET, so that any motion that's part of a command is
357 {v_first
, V_CNT
|V_MOVE
|V_RCM_SET
,
359 " ^ move to first non-blank"},
362 * DON'T set the V_RCM_SETFNB flag, the function has to do
363 * the work anyway, in case it's a motion component. DO set
364 * V_RCM_SET, so that any motion that's part of a command is
367 {v_cfirst
, V_CNT
|V_MOVE
|V_RCM_SET
,
369 " _ move to first non-blank"},
371 {v_gomark
, V_ABS
|V_CHAR
|V_MOVE
|V_RCM_SET
,
375 {v_ia
, V_CNT
|V_DOT
|V_RCM_SET
,
377 " a append after cursor"},
379 {v_wordb
, V_CNT
|V_MOVE
|V_RCM_SET
,
381 " b move back word"},
383 {v_change
, V_CNT
|V_DOT
|V_MOTION
|V_OBUF
|V_RCM_SET
|VC_C
,
384 "[buffer][count]c[count]motion",
385 " c change to motion"},
387 {v_delete
, V_CNT
|V_DOT
|V_MOTION
|V_OBUF
|V_RCM_SET
|VC_D
,
388 "[buffer][count]d[count]motion",
389 " d delete to motion"},
391 {v_worde
, V_CNT
|V_MOVE
|V_RCM_SET
,
393 " e move to end of word"},
395 {v_chf
, V_CHAR
|V_CNT
|V_MOVE
|V_RCM_SET
,
396 "[count]f character",
397 " f character in line forward search"},
401 {v_left
, V_CNT
|V_MOVE
|V_RCM_SET
,
403 " h move left by columns"},
405 {v_ii
, V_CNT
|V_DOT
|V_RCM_SET
,
407 " i insert before cursor"},
409 {v_down
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM
,
411 " j move down by lines"},
413 {v_up
, V_CNT
|V_LMODE
|V_MOVE
|V_RCM
,
415 " k move up by lines"},
417 {v_right
, V_CNT
|V_MOVE
|V_RCM_SET
,
419 " l move right by columns"},
425 {v_searchn
, V_ABS
|V_MOVE
|V_RCM_SET
,
427 " n repeat last search"},
429 {v_io
, V_CNT
|V_DOT
|V_RCM_SET
,
431 " o append after line"},
433 {v_put
, V_CNT
|V_DOT
|V_OBUF
|V_RCM_SET
,
435 " p insert after cursor from buffer"},
439 {v_replace
, V_CNT
|V_DOT
|V_RCM_SET
,
440 "[count]r character",
441 " r replace character"},
443 {v_subst
, V_CNT
|V_DOT
|V_OBUF
|V_RCM_SET
,
445 " s substitute character"},
447 {v_cht
, V_CHAR
|V_CNT
|V_MOVE
|V_RCM_SET
,
448 "[count]t character",
449 " t before character in line forward search"},
452 * DON'T set the V_DOT flag, it' more complicated than that.
453 * See vi/vi.c for details.
457 " u undo last change"},
461 {v_wordw
, V_CNT
|V_MOVE
|V_RCM_SET
,
463 " w move to next word"},
465 {v_xchar
, V_CNT
|V_DOT
|V_OBUF
|V_RCM_SET
,
467 " x delete character"},
469 {v_yank
, V_CNT
|V_MOTION
|V_OBUF
|V_RCM_SET
|VC_Y
,
470 "[buffer][count]y[count]motion",
471 " y copy text to motion into a cut buffer"},
474 * DON'T set the V_CHAR flag, the char isn't required,
475 * so it's handled specially in getcmd().
477 {v_z
, V_CNT
|V_RCM_SETFNB
,
478 "[line]z[window_size][-|.|+|^|<CR>]",
481 {v_paragraphb
, V_ABS
|V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SET
,
483 " { move back paragraph"},
485 {v_ncol
, V_ABS
|V_CNT
|V_MOVE
|V_RCM_SET
,
487 " | move to column"},
489 {v_paragraphf
, V_ABS
|V_CNT
|V_LMODE
|V_MOVE
|V_RCM_SET
,
491 " } move forward paragraph"},
493 {v_ulcase
, V_CNT
|V_DOT
|V_RCM_SET
,