1 .\" $OpenBSD: editline.7,v 1.2 2016/05/10 11:07:53 schwarze Exp $
3 .\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: May 10 2016 $
22 .Nd line editing user interface
24 When a program using the
26 library prompts for an input string using the function
28 it reads characters from the terminal.
29 Invalid input bytes that do not form characters are silently
31 For each character read, one editor command is executed.
32 The mapping of input characters to editor commands depends on the
34 There are three editing modes: vi insert mode, vi command mode,
36 The default is vi insert mode.
37 The program can switch the default to emacs mode by using the
41 functions, and the user can switch to emacs mode either in the
43 configuration file or interactively with the
45 editor command, in all three cases executing the
49 If trying to read from the terminal results in end of file or an
50 error, the library signals end of file to the program and does not
52 .Ss Input character bindings
53 All default bindings described below can be overridden by individual
54 programs and can be changed with the
59 In the following tables,
61 indicates a character with the bit 0x40 flipped, and
63 indicates a character with the bit 0x80 set.
64 In vi insert mode and in emacs mode, all Meta-characters considered
65 printable by the current
69 instead of to the editor command listed below.
70 Consequently, in UTF-8 mode, most of the Meta-characters are not
71 directly accessible because their code points are occupied by
72 printable Unicode characters, and Meta-characters are usually input
80 editor command in emacs mode, call
82 by pressing and releasing the escape key (or equivalently, Ctrl-[),
83 then press and release the
86 If you have configured a Meta-key on your keyboard, for example
88 .Ql setxkbmap -option altwin:left_meta_win ,
89 the Ctrl-Meta-characters are directly accessible.
93 .Ic ed-delete-prev-word
94 editor command in emacs mode, hold down the keys
100 Alternatively, press and release the escape key, then press and
104 In vi input mode, input characters are bound to the following editor
106 .Bl -column -offset indent "Ctrl-Z, TSTP" "ed-search-next-history"
107 .It Ctrl-D, EOF Ta Ic vi-list-or-eof
108 .It Ctrl-H, BS Ta Ic vi-delete-prev-char
109 .It Ctrl-J, LF Ta Ic ed-newline
110 .It Ctrl-M, CR Ta Ic ed-newline
111 .It Ctrl-Q Ta Ic ed-tty-start-output
112 .It Ctrl-S Ta Ic ed-tty-stop-output
113 .It Ctrl-U Ta Ic vi-kill-line-prev
114 .It Ctrl-V Ta Ic ed-quoted-insert
115 .It Ctrl-W Ta Ic ed-delete-prev-word
116 .It Ctrl-[, ESC Ta Ic vi-command-mode
117 .It Ctrl-\e, QUIT Ta Ic ed-tty-sigquit
118 .It Ctrl-?, DEL Ta Ic vi-delete-prev-char
121 All other input characters except the NUL character (Ctrl-@) are
125 In vi command mode, input characters are bound to the following
126 editor commands by default:
127 .Bl -column -offset indent "Ctrl-Z, TSTP" "ed-search-next-history"
128 .It Ctrl-A Ta Ic ed-move-to-beg
129 .It Ctrl-C, INT Ta Ic ed-tty-sigint
130 .It Ctrl-E Ta Ic ed-move-to-end
131 .It Ctrl-H, BS Ta Ic ed-delete-prev-char
132 .It Ctrl-J, LF Ta Ic ed-newline
133 .It Ctrl-K Ta Ic ed-kill-line
134 .It Ctrl-L, FF Ta Ic ed-clear-screen
135 .It Ctrl-M, CR Ta Ic ed-newline
136 .It Ctrl-N Ta Ic ed-next-history
137 .It Ctrl-O Ta Ic ed-tty-flush-output
138 .It Ctrl-P Ta Ic ed-prev-history
139 .It Ctrl-Q Ta Ic ed-tty-start-output
140 .It Ctrl-R Ta Ic ed-redisplay
141 .It Ctrl-S Ta Ic ed-tty-stop-output
142 .It Ctrl-U Ta Ic vi-kill-line-prev
143 .It Ctrl-W Ta Ic ed-delete-prev-word
144 .It Ctrl-[, ESC Ta Ic em-meta-next
145 .It Ctrl-\e, QUIT Ta Ic ed-tty-sigquit
146 .It Space Ta Ic ed-next-char
147 .It # Ta Ic vi-comment-out
148 .It $ Ta Ic ed-move-to-end
150 .It + Ta Ic ed-next-history
151 .It \&, Ta Ic vi-repeat-prev-char
152 .It - Ta Ic ed-prev-history
153 .It \&. Ta Ic vi-redo
154 .It / Ta Ic vi-search-prev
156 .It 1 to 9 Ta Ic ed-argument-digit
157 .It \&: Ta Ic ed-command
158 .It \&; Ta Ic vi-repeat-next-char
159 .It \&? Ta Ic vi-search-next
161 .It A Ta Ic vi-add-at-eol
162 .It B Ta Ic vi-prev-big-word
163 .It C Ta Ic vi-change-to-eol
164 .It D Ta Ic ed-kill-line
165 .It E Ta Ic vi-end-big-word
166 .It F Ta Ic vi-prev-char
167 .It G Ta Ic vi-to-history-line
168 .It I Ta Ic vi-insert-at-bol
169 .It J Ta Ic ed-search-next-history
170 .It K Ta Ic ed-search-prev-history
171 .It N Ta Ic vi-repeat-search-prev
172 .It O Ta Ic ed-sequence-lead-in
173 .It P Ta Ic vi-paste-prev
174 .It R Ta Ic vi-replace-mode
175 .It S Ta Ic vi-substitute-line
176 .It T Ta Ic vi-to-prev-char
177 .It U Ta Ic vi-undo-line
178 .It W Ta Ic vi-next-big-word
179 .It X Ta Ic ed-delete-prev-char
180 .It Y Ta Ic vi-yank-end
181 .It \&[ Ta Ic ed-sequence-lead-in
182 .It ^ Ta Ic ed-move-to-beg
183 .It _ Ta Ic vi-history-word
185 .It b Ta Ic vi-prev-word
186 .It c Ta Ic vi-change-meta
187 .It d Ta Ic vi-delete-meta
188 .It e Ta Ic vi-end-word
189 .It f Ta Ic vi-next-char
190 .It h Ta Ic ed-prev-char
191 .It i Ta Ic vi-insert
192 .It j Ta Ic ed-next-history
193 .It k Ta Ic ed-prev-history
194 .It l Ta Ic ed-next-char
195 .It n Ta Ic vi-repeat-search-next
196 .It p Ta Ic vi-paste-next
197 .It r Ta Ic vi-replace-char
198 .It s Ta Ic vi-substitute-char
199 .It t Ta Ic vi-to-next-char
201 .It v Ta Ic vi-histedit
202 .It w Ta Ic vi-next-word
203 .It x Ta Ic ed-delete-next-char
205 .It \&| Ta Ic vi-to-column
206 .It ~ Ta Ic vi-change-case
207 .It Ctrl-?, DEL Ta Ic ed-delete-prev-char
208 .It Meta-O Ta Ic ed-sequence-lead-in
209 .It Meta-[ Ta Ic ed-sequence-lead-in
212 In emacs mode, input characters are bound to the following editor
214 .Bl -column -offset indent "Ctrl-Z, TSTP" "ed-search-next-history"
215 .It 0 to 9 Ta Ic ed-digit
216 .It Ctrl-@, NUL Ta Ic em-set-mark
217 .It Ctrl-A Ta Ic ed-move-to-beg
218 .It Ctrl-B Ta Ic ed-prev-char
219 .It Ctrl-C, INT Ta Ic ed-tty-sigint
220 .It Ctrl-D, EOF Ta Ic em-delete-or-list
221 .It Ctrl-E Ta Ic ed-move-to-end
222 .It Ctrl-F Ta Ic ed-next-char
223 .It Ctrl-H, BS Ta Ic em-delete-prev-char
224 .It Ctrl-J, LF Ta Ic ed-newline
225 .It Ctrl-K Ta Ic ed-kill-line
226 .It Ctrl-L, FF Ta Ic ed-clear-screen
227 .It Ctrl-M, CR Ta Ic ed-newline
228 .It Ctrl-N Ta Ic ed-next-history
229 .It Ctrl-O Ta Ic ed-tty-flush-output
230 .It Ctrl-P Ta Ic ed-prev-history
231 .It Ctrl-Q Ta Ic ed-tty-start-output
232 .It Ctrl-R Ta Ic ed-redisplay
233 .It Ctrl-S Ta Ic ed-tty-stop-output
234 .It Ctrl-T Ta Ic ed-transpose-chars
235 .It Ctrl-U Ta Ic ed-kill-line
236 .It Ctrl-V Ta Ic ed-quoted-insert
237 .It Ctrl-W Ta Ic em-kill-region
238 .It Ctrl-X Ta Ic ed-sequence-lead-in
239 .It Ctrl-Y Ta Ic em-yank
240 .It Ctrl-Z, TSTP Ta Ic ed-tty-sigtstp
241 .It Ctrl-[, ESC Ta Ic em-meta-next
242 .It Ctrl-\e, QUIT Ta Ic ed-tty-sigquit
243 .It Ctrl-] Ta Ic ed-tty-dsusp
244 .It Ctrl-?, DEL Ta Ic em-delete-prev-char
245 .It Ctrl-Meta-H Ta Ic ed-delete-prev-word
246 .It Ctrl-Meta-L Ta Ic ed-clear-screen
247 .It Ctrl-Meta-_ Ta Ic em-copy-prev-word
248 .It Meta-0 to 9 Ta Ic ed-argument-digit
249 .It Meta-B Ta Ic ed-prev-word
250 .It Meta-C Ta Ic em-capitol-case
251 .It Meta-D Ta Ic em-delete-next-word
252 .It Meta-F Ta Ic em-next-word
253 .It Meta-L Ta Ic em-lower-case
254 .It Meta-N Ta Ic ed-search-next-history
255 .It Meta-O Ta Ic ed-sequence-lead-in
256 .It Meta-P Ta Ic ed-search-prev-history
257 .It Meta-U Ta Ic em-upper-case
258 .It Meta-W Ta Ic em-copy-region
259 .It Meta-X Ta Ic ed-command
260 .It Meta-[ Ta Ic ed-sequence-lead-in
261 .It Meta-b Ta Ic ed-prev-word
262 .It Meta-c Ta Ic em-capitol-case
263 .It Meta-d Ta Ic em-delete-next-word
264 .It Meta-f Ta Ic em-next-word
265 .It Meta-l Ta Ic em-lower-case
266 .It Meta-n Ta Ic ed-search-next-history
267 .It Meta-p Ta Ic ed-search-prev-history
268 .It Meta-u Ta Ic em-upper-case
269 .It Meta-w Ta Ic em-copy-region
270 .It Meta-x Ta Ic ed-command
271 .It Ctrl-Meta-? Ta Ic ed-delete-prev-word
276 characters in the range 0x20 to 0x7e are bound to
279 If standard output is not connected to a terminal device
284 to 0, all input character bindings are disabled and all characters
285 typed are appended to the edit buffer.
286 In that case, the edit buffer is returned to the program after a
287 newline or carriage return character is typed, or after the first
294 Most editor commands accept an optional argument.
295 The argument is entered by prefixing the editor command with one
296 or more of the editor commands
297 .Ic ed-argument-digit ,
299 .Ic em-universal-argument ,
302 When an argument is not provided, it defaults to 1.
303 For most editor commands, the effect of an argument is to repeatedly
304 execute the command that number of times.
306 When talking about a character string from a left character to a
307 right character, the left character is included in the string, while
308 the right character is not included.
310 If an editor command causes an error, the input character is discarded,
311 no action occurs, and the terminal bell is rung.
312 In case of a non-fatal error, the terminal bell is also rung,
313 but the editor command takes effect anyway.
315 In the following list, the default key bindings are listed after
318 .It Ic ed-argument-digit Pq vi command: 1 to 9; emacs: Meta-0 to Meta-9
319 If in argument input mode, append the input digit to the argument
321 Otherwise, switch to argument input mode and use the input digit
322 as the most significant digit of the argument.
323 It is an error if the input character is not a digit or if the
324 existing argument is already greater than a million.
325 .It Ic ed-clear-screen Pq vi command: Ctrl-L; emacs: Ctrl-L, Ctrl-Meta-L
326 Clear the screen and display the edit buffer at the top.
328 .It Ic ed-command Pq vi command: So \&: Sc ; emacs: Meta-X, Meta-x
329 Read a line from the terminal bypassing the normal line editing
330 functionality and execute that line as an
333 If in vi command mode, also switch back to vi insert mode.
335 .It Ic ed-delete-next-char Pq vi command: x
336 Delete the character at the cursor position.
337 With an argument, delete that number of characters.
338 In emacs mode, it is an error if the cursor is at the end of the
340 In vi mode, the last character in the edit buffer is deleted in
341 that case, and it is an error if the buffer is empty.
342 .It Ic ed-delete-prev-char Pq vi command: X, Ctrl-H, BS, Ctrl-?, DEL
343 Delete the character to the left of the cursor position.
344 With an argument, delete that number of characters.
345 It is an error if the cursor is at the beginning of the edit buffer.
346 .It Ic ed-delete-prev-word Pq vi: Ctrl-W; emacs: Ctrl-Meta-H, Ctrl-Meta-?
347 Move to the left to the closest beginning of a word, delete the
348 string from that position to the cursor, and save it to the cut
350 With an argument, delete that number of words.
351 It is an error if the cursor is at the beginning of the edit buffer.
352 .It Ic ed-digit Pq emacs: 0 to 9
353 If in argument input mode, append the input digit to the argument
357 It is an error if the input character is not a digit or if the
358 existing argument is already greater than a million.
359 .It Ic ed-end-of-file Pq not bound by default
360 Discard the edit buffer and indicate end of file to the program.
362 .It Ic ed-ignore Pq various
363 Discard the input character and do nothing.
364 .It Ic ed-insert Pq vi input: almost all; emacs: printable characters
365 In insert mode, insert the input character left of the cursor
367 In replace mode, overwrite the character at the cursor and move the
368 cursor to the right by one character position.
369 Accept an argument to do this repeatedly.
370 It is an error if the input character is the NUL character (Ctrl-@).
371 Failure to enlarge the edit buffer also results in an error.
372 .It Ic ed-kill-line Pq vi command: D, Ctrl-K; emacs: Ctrl-K, Ctrl-U
373 Delete the string from the cursor position to the end of the line
374 and save it to the cut buffer.
376 .It Ic ed-move-to-beg Pq vi command: ^, Ctrl-A; emacs: Ctrl-A
377 In vi mode, move the cursor to the first non-space character in the
379 In emacs mode, move the cursor to the beginning of the edit buffer.
381 Can be used as a movement command after
386 .It Ic ed-move-to-end Pq vi command: $, Ctrl-E; emacs: Ctrl-E
387 Move the cursor to the end of the edit buffer.
389 Can be used as a movement command after
394 .It Ic ed-newline Pq all modes: Ctrl-J, LF, Ctrl-M, CR
395 Append a newline character to the edit buffer and return the edit
396 buffer to the program.
398 .It Ic ed-next-char Pq vi command: Space, l; emacs: Ctrl-F
399 Move the cursor one character position to the right.
400 With an argument, move by that number of characters.
401 Can be used as a movement command after
406 It is an error if the cursor is already at the end of the edit
408 .It Ic ed-next-history Pq vi command: j, +, Ctrl-N; emacs: Ctrl-N
409 Replace the edit buffer with the next history line.
410 That line is older than the current line.
411 With an argument, go forward by that number of history lines.
412 It is a non-fatal error to advance by more lines than are available.
413 .It Ic ed-next-line Pq not bound by default
414 Move the cursor down one line.
415 With an argument, move down by that number of lines.
416 It is an error if the edit buffer does not contain enough newline
417 characters to the right of the cursor position.
418 .It Ic ed-prev-char Pq vi command: h; emacs: Ctrl-B
419 Move the cursor one character position to the left.
420 With an argument, move by that number of characters.
421 Can be used as a movement command after
426 It is an error if the cursor is already at the beginning of the
428 .It Ic ed-prev-history Pq vi command: k, -, Ctrl-P; emacs: Ctrl-P
429 Replace the edit buffer with the previous history line.
430 That line is newer than the current line.
431 With an argument, go back by that number of lines.
432 It is a non-fatal error to back up by more lines than are available.
433 .It Ic ed-prev-line Pq not bound by default
434 Move the cursor up one line.
435 With an argument, move up by that number of lines.
436 It is an error if the edit buffer does not contain enough newline
437 characters to the left of the cursor position.
438 .It Ic ed-prev-word Pq emacs: Meta-B, Meta-b
439 Move the cursor to the left to the closest beginning of a word.
440 With an argument, repeat that number of times.
441 Can be used as a movement command after
446 It is an error if the cursor is already at the beginning of the
448 .It Ic ed-quoted-insert Pq vi insert, emacs: Ctrl-V
449 Read one character from the terminal bypassing the normal line
450 editing functionality and call
453 If trying to read the character returns end of file or an error,
457 .It Ic ed-redisplay Pq vi command, emacs: Ctrl-R
458 Redisplay everything.
460 .It Ic ed-search-next-history Pq vi command: J; emacs: Meta-N, Meta-n
461 Replace the edit buffer with the next matching history entry.
462 .It Ic ed-search-prev-history Pq vi command: K; emacs: Meta-P, Meta-p
463 Replace the edit buffer with the previous matching history entry.
464 .It Ic ed-sequence-lead-in Pq vi cmd: O, \&[; emacs: Ctrl-X;\
467 See the section about
470 .It Ic ed-start-over Pq not bound by default
471 Discard the contents of the edit buffer and start from scratch.
473 .It Ic ed-transpose-chars Pq emacs: Ctrl-T
474 Exchange the character at the cursor position with the one to the
475 left of it and move the cursor to the character to the right of the
476 two exchanged characters.
478 It is an error if the cursor is at the beginning of the edit buffer
479 or if the edit buffer contains less than two characters.
480 .It Ic ed-unassigned Pq all characters not listed
481 This editor command always results in an error.
482 .It Ic em-capitol-case Pq emacs: Meta-C, Meta-c
483 Capitalize the string from the cursor to the end of the current
485 That is, if it contains at least one alphabetic character, convert
486 the first alphabetic character to upper case, and convert all
487 characters to the right of it to lower case.
488 In any case, move the cursor to the next character after the end
490 .It Ic em-copy-prev-word Pq emacs: Ctrl-Meta-_
491 Copy the string from the beginning of the current word to the cursor
492 and insert it to the left of the cursor.
493 Move the cursor to the character after the inserted string.
494 It is an error if the cursor is at the beginning of the edit buffer.
495 .It Ic em-copy-region Pq emacs: Meta-W, Meta-w
496 Copy the string from the cursor to the mark to the cut buffer.
497 It is an error if the mark is not set.
498 .It Ic em-delete-next-word Pq emacs: Meta-D, Meta-d
499 Delete the string from the cursor to the end of the current word
500 and save it to the cut buffer.
501 It is an error if the cursor is at the end of the edit buffer.
502 .It Ic em-delete-or-list Pq emacs: Ctrl-D, EOF
503 If the cursor is not at the end of the line, delete the character
505 If the edit buffer is empty, indicate end of file to the program.
506 It is an error if the cursor is at the end of the edit buffer and
507 the edit buffer is not empty.
508 .It Ic em-delete-prev-char Pq emacs: Ctrl-H, BS, Ctrl-?, DEL
509 Delete the character to the left of the cursor.
510 It is an error if the cursor is at the beginning of the edit buffer.
511 .It Ic em-exchange-mark Pq not bound by default
512 Exchange the cursor and the mark.
513 .It Ic em-gosmacs-transpose Pq not bound by default
514 Exchange the two characters to the left of the cursor.
515 It is an error if the cursor is on the first or second character
517 .It Ic em-inc-search-next Pq not bound by default
518 Emacs incremental next search.
519 .It Ic em-inc-search-prev Pq not bound by default
520 Emacs incremental reverse search.
521 .It Ic em-kill-line Pq not bound by default
522 Delete the entire contents of the edit buffer and save it to the
524 .It Ic em-kill-region Pq emacs: Ctrl-W
525 Delete the string from the cursor to the mark and save it to the
527 It is an error if the mark is not set.
528 .It Ic em-lower-case Pq emacs: Meta-L, Meta-l
529 Convert the characters from the cursor to the end of the current
531 .It Ic em-meta-next Pq vi command, emacs: Ctrl-[, ESC
532 Set the bit 0x80 on the next character typed.
533 Unless the resulting code point is printable, holding down the
535 key while typing that character is a simpler way to achieve the
537 .It Ic em-next-word Pq Meta-F, Meta-f
538 Move the cursor to the end of the current word.
539 Can be used as a movement command after
544 It is an error if the cursor is already at the end of the edit
546 .It Ic em-set-mark Pq emacs: Ctrl-Q, NUL
547 Set the mark at the current cursor position.
548 .It Ic em-toggle-overwrite Pq not bound by default
549 Switch from insert to overwrite mode or vice versa.
550 .It Ic em-universal-argument Pq not bound by default
551 If in argument input mode, multiply the argument by 4.
552 Otherwise, switch to argument input mode and set the argument to 4.
553 It is an error if the existing argument is already greater than a
555 .It Ic em-upper-case Pq emacs: Meta-U, Meta-u
556 Convert the characters from the cursor to the end of the current
558 .It Ic em-yank Pq emacs: Ctrl-Y
559 Paste the cut buffer to the left of the cursor.
560 .It Ic vi-add Pq vi command: a
561 Switch to vi insert mode.
562 Unless the cursor is already at the end of the edit buffer, move
563 it one character position to the right.
564 .It Ic vi-add-at-eol Pq vi command: A
565 Switch to vi insert mode and move the cursor to the end of the edit
567 .It Ic vi-alias Pq vi command: @
568 If an alias function was defined by calling the
572 function with the argument
574 read one character from the terminal bypassing the normal line
575 editing functionality, call the alias function passing the argument that was specified with
577 as the first argument and the character read, with an underscore
578 prepended, as the second argument, and pass the string returned
579 from the alias function to
581 It is an error if no alias function is defined or if trying to read
582 the character results in end of file or an error.
583 .It Ic vi-change-case Pq vi command: ~
584 Change the case of the character at the cursor and move the cursor
585 one character position to the right.
586 It is an error if the cursor is already at the end of the edit
588 .It Ic vi-change-meta Pq vi command: c
589 Delete the string from the cursor to the position specified by the
590 following movement command and save a copy of it to the cut buffer.
591 When given twice in a row, instead delete the whole contents of the
592 edit buffer and save a copy of it to the cut buffer.
593 In either case, switch to vi insert mode after that.
594 .It Ic vi-change-to-eol Pq vi command: C
595 Delete the string from the cursor position to the end of the line
596 and save it to the cut buffer, then switch to vi insert mode.
597 .It Ic vi-command-mode Pq vi insert: Ctrl-[, ESC
598 Discard pending actions and arguments and switch to vi command mode.
599 Unless the cursor is already at the beginning of the edit buffer,
600 move it to the left by one character position.
601 .It Ic vi-comment-out Pq vi command: #
604 character at the beginning of the edit buffer and return the edit
605 buffer to the program.
606 .It Ic vi-delete-meta Pq vi command: d
607 Delete the string from the cursor to the position specified by the
608 following movement command and save a copy of it to the cut buffer.
609 When given twice in a row, instead delete the whole contents of the
610 edit buffer and save a copy of it to the cut buffer.
611 .It Ic vi-delete-prev-char Pq vi insert: Ctrl-H, BS, Ctrl-?, DEL
612 Delete the character to the left of the cursor.
613 It is an error if the cursor is already at the beginning of the
615 .It Ic vi-end-big-word Pq vi command: E
616 Move the cursor to the end of the current space delimited word.
617 Can be used as a movement command after
622 It is an error if the cursor is already at the end of the edit
624 .It Ic vi-end-word Pq vi command: e
625 Move the cursor to the end of the current word.
626 Can be used as a movement command after
631 It is an error if the cursor is already at the end of the edit
633 .It Ic vi-history-word Pq vi command: _
634 Insert the first word from the most recent history entry after the
635 cursor, move the cursor after to the character after the inserted
636 word, and switch to vi insert mode.
637 It is an error if there is no history entry or the most recent
638 history entry is empty.
639 .It Ic vi-insert Pq vi command: i
641 .It Ic vi-insert-at-bol Pq vi command: I
642 Move the cursor to the beginning of the edit buffer and switch to
644 .It Ic vi-kill-line-prev Pq vi: Ctrl-U
645 Delete the string from the beginning of the edit buffer to the
646 cursor and save it to the cut buffer.
647 .It Ic vi-list-or-eof Pq vi insert: Ctrl-D, EOF
648 If the edit buffer is empty, indicate end of file to the program.
649 It is an error if the edit buffer is not empty.
650 .It Ic vi-match Pq vi command: %
651 Consider opening and closing parentheses, braces, and brackets as
653 If the cursor is not at a delimiter, move it to the right until it
654 gets to one, then move it to the matching delimiter.
655 Can be used as a movement command after
660 It is an error if there is no delimiter at the cursor or in the
661 string to the right of the cursor, or if the first such delimiter
662 has no matching delimiter.
663 .It Ic vi-next-big-word Pq vi command: W
664 Move the cursor to the right to the beginning of the next space
666 Can be used as a movement command after
671 It is an error if the cursor is already at the end of the edit
672 buffer or on its last character.
673 .It Ic vi-next-char Pq vi command: f
674 Read one character from the terminal bypassing the normal line
675 editing functionality and move the cursor to the right to the next
676 instance of that character in the edit buffer.
677 Can be used as a movement command after
682 If trying to read the character results in end of file or an error,
686 It is an error if the character is not found searching to the right
688 .It Ic vi-next-word Pq vi command: w
689 Move the cursor to the right to the beginning of the next word.
690 Can be used as a movement command after
695 It is an error if the cursor is already at the end of the edit
696 buffer or on its last character.
697 .It Ic vi-paste-next Pq vi command: p
698 Insert a copy of the cut buffer to the right of the cursor.
699 It is an error if the cut buffer is empty.
700 .It Ic vi-paste-prev Pq vi command: P
701 Insert a copy of the cut buffer to the left of the cursor.
702 It is an error if the cut buffer is empty.
703 .It Ic vi-prev-big-word Pq vi command: B
704 Move the cursor to the left to the next beginning of a space delimited
706 Can be used as a movement command after
711 It is an error if the cursor is already at the beginning of the
713 .It Ic vi-prev-char Pq vi command: F
714 Read one character from the terminal bypassing the normal line
715 editing functionality and move the cursor to the left to the next
716 instance of that character in the edit buffer.
717 Can be used as a movement command after
722 If trying to read the character results in end of file or an error,
726 It is an error if the character is not found searching to the left
728 .It Ic vi-prev-word Pq vi command: b
729 Move the cursor to the left to the next beginning of a word.
730 Can be used as a movement command after
735 It is an error if the cursor is already at the beginning of the
737 .It Ic vi-redo Pq vi command: Sq \&.
738 Redo the last non-motion command.
739 .It Ic vi-repeat-next-char Pq vi command: Sq \&;
740 Repeat the most recent character search in the same search direction.
741 Can be used as a movement command after
746 .It Ic vi-repeat-prev-char Pq vi command: Sq \&,
747 Repeat the most recent character search in the opposite search
749 Can be used as a movement command after
754 .It Ic vi-repeat-search-next Pq vi command: n
755 Repeat the most recent history search in the same search direction.
756 .It Ic vi-repeat-search-prev Pq vi command: N
757 Repeat the most recent history search in the opposite search
759 .It Ic vi-replace-char Pq vi command: r
760 Switch to vi replace mode, and automatically switch back to vi
761 command mode after the next character typed.
764 for a description of replace mode.
765 It is an error if the cursor is at the end of the edit buffer.
766 .It Ic vi-replace-mode Pq vi command: R
767 Switch to vi replace mode.
768 This is a variant of vi insert mode; see
771 .It Ic vi-search-next Pq vi command: \&?
772 Replace the edit buffer with the next matching history entry.
773 .It Ic vi-search-prev Pq vi command: /
774 Replace the edit buffer with the previous matching history entry.
775 .It Ic vi-substitute-char Pq vi command: s
776 Delete the character at the cursor and switch to vi insert mode.
777 .It Ic vi-substitute-line Pq vi command: S
778 Delete the entire contents of the edit buffer, save a copy of it
779 in the cut buffer, and enter vi insert mode.
780 .It Ic vi-to-column Pq vi command: \&|
781 Move the cursor to the column specified as the argument.
782 Can be used as a movement command after
787 .It Ic vi-to-history-line Pq vi command: G
788 Replace the edit buffer with the specified history entry.
789 .It Ic vi-to-next-char Pq vi command: t
790 Read one character from the terminal bypassing the normal line
791 editing functionality and move the cursor to the right to the
792 character before the next instance of that character in the edit
794 Can be used as a movement command after
799 If trying to read the character results in end of file or an error,
803 It is an error if the character is not found searching to the right
805 .It Ic vi-to-prev-char Pq vi command: T
806 Read one character from the terminal bypassing the normal line
807 editing functionality and move the cursor to the left to the character
808 after the next instance of that character in the edit buffer.
809 Can be used as a movement command after
814 If trying to read the character results in end of file or an error,
818 It is an error if the character is not found searching to the left
820 .It Ic vi-undo Pq vi command: u
821 Undo the last change.
822 .It Ic vi-undo-line Pq vi command: U
823 Undo all changes to the edit buffer.
824 .It Ic vi-yank Pq vi command: y
825 Copy the string from the cursor to the position specified by the
826 following movement command to the cut buffer.
827 When given twice in a row, instead copy the whole contents of the
828 edit buffer to the cut buffer.
829 .It Ic vi-yank-end Pq vi command: Y
830 Copy the string from the cursor to the end of the edit buffer to
832 .It Ic vi-zero Pq vi command: 0
833 If in argument input mode, multiply the argument by ten.
834 Otherwise, move the cursor to the beginning of the edit buffer.
835 Can be used as a movement command after
842 If an input character is bound to the editor command
843 .Ic ed-sequence-lead-in ,
845 attempts to call a macro.
846 If the input character by itself forms the name of a macro, that
848 Otherwise, additional input characters are read until the string
849 read forms the name of a macro, in which case that macro is executed,
850 or until the string read matches the beginning of none of the existing
851 macro names, in which case the string including the final, mismatching
852 character is discarded and the terminal bell is rung.
854 There are two kinds of macros.
855 Command macros execute a single editor command.
856 Keyboard macros return a string of characters that is appended
860 The following command macros are defined by default in vi command
861 mode and in emacs mode:
862 .Bl -column -offset indent "Esc O A, Esc O A" "em-exchange-mark"
863 .It Esc \&[ A, Esc O A Ta Ic ed-prev-history
864 .It Esc \&[ B, Esc O B Ta Ic ed-next-history
865 .It Esc \&[ C, Esc O C Ta Ic ed-next-char
866 .It Esc \&[ D, Esc O D Ta Ic ed-prev-char
867 .It Esc \&[ F, Esc O F Ta Ic ed-move-to-end
868 .It Esc \&[ H, Esc O H Ta Ic ed-move-to-beg
871 In vi command mode, they are also defined by default without the
872 initial escape character.
876 library tries to bind the strings generated by the arrow keys
879 database to these editor commands, unless that would clobber
882 In emacs mode, the two-character string
890 library maintains an input queue operated in FIFO mode.
891 Whenever it needs an input character, it takes the first character
892 from the first line of the input queue.
893 When the queue is empty, it reads from the terminal.
895 A line can be appended to the end of the input queue in several ways:
896 .Bl -dash -offset indent
898 By calling one of the keyboard
901 By calling the editor command
904 By calling the editor command
907 By pressing a key in emacs incremental search mode that doesn't
908 have a special meaning in that mode but returns to normal emacs
911 If an application program directly calls the functions
915 it can provide additional, program-specific ways
916 of appending to the input queue.
924 This manual page first appeared in
928 This manual page was written by
929 .An Ingo Schwarze Aq Mt schwarze@openbsd.org .