1EDITLINE(7)          BSD Miscellaneous Information Manual          EDITLINE(7)
2

NAME

4     editline — line editing user interface
5

DESCRIPTION

7     When a program using the editline(3) library prompts for an input string
8     using the function el_wgets(3), it reads characters from the terminal.
9     Invalid input bytes that do not form characters are silently discarded.
10     For each character read, one editor command is executed.  The mapping of
11     input characters to editor commands depends on the editing mode.  There
12     are three editing modes: vi insert mode, vi command mode, and emacs mode.
13     The default is vi insert mode.  The program can switch the default to
14     emacs mode by using the el_set(3) or el_parse(3) functions, and the user
15     can switch to emacs mode either in the editrc(5) configuration file or
16     interactively with the ed-command editor command, in all three cases exe‐
17     cuting the bind -e builtin command.
18
19     If trying to read from the terminal results in end of file or an error,
20     the library signals end of file to the program and does not return a
21     string.
22
23   Input character bindings
24     All default bindings described below can be overridden by individual pro‐
25     grams and can be changed with the editrc(5) bind builtin command.
26
27     In the following tables, ‘Ctrl-’ indicates a character with the bit 0x40
28     flipped, and ‘Meta-’ indicates a character with the bit 0x80 set.  In vi
29     insert mode and in emacs mode, all Meta-characters considered printable
30     by the current locale(1) are bound to ed-insert instead of to the editor
31     command listed below.  Consequently, in UTF-8 mode, most of the Meta-
32     characters are not directly accessible because their code points are
33     occupied by printable Unicode characters, and Meta-characters are usually
34     input using the em-meta-next editor command.  For example, to enter
35     ‘Meta-B’ in order to call the ed-prev-word editor command in emacs mode,
36     call em-meta-next by pressing and releasing the escape key (or equiva‐
37     lently, Ctrl-[), then press and release the ‘B’ key.  If you have config‐
38     ured a Meta-key on your keyboard, for example with ‘setxkbmap -option
39     altwin:left_meta_win’, the Ctrl-Meta-characters are directly accessible.
40     For example, to enter ‘Ctrl-Meta-H’ in order to call the
41     ed-delete-prev-word editor command in emacs mode, hold down the keys
42     ‘Ctrl’, ‘Meta’, and ‘H’ at the same time.  Alternatively, press and
43     release the escape key, then press and release ‘Ctrl-H’.
44
45     In vi input mode, input characters are bound to the following editor com‐
46     mands by default:
47
48           Ctrl-D, EOF     vi-list-or-eof
49           Ctrl-H, BS      vi-delete-prev-char
50           Ctrl-J, LF      ed-newline
51           Ctrl-M, CR      ed-newline
52           Ctrl-Q          ed-tty-start-output
53           Ctrl-S          ed-tty-stop-output
54           Ctrl-U          vi-kill-line-prev
55           Ctrl-V          ed-quoted-insert
56           Ctrl-W          ed-delete-prev-word
57           Ctrl-[, ESC     vi-command-mode
58           Ctrl-\, QUIT    ed-tty-sigquit
59           Ctrl-?, DEL     vi-delete-prev-char
60
61     All other input characters except the NUL character (Ctrl-@) are bound to
62     ed-insert.
63
64     In vi command mode, input characters are bound to the following editor
65     commands by default:
66
67           Ctrl-A          ed-move-to-beg
68           Ctrl-C, INT     ed-tty-sigint
69           Ctrl-E          ed-move-to-end
70           Ctrl-H, BS      ed-delete-prev-char
71           Ctrl-J, LF      ed-newline
72           Ctrl-K          ed-kill-line
73           Ctrl-L, FF      ed-clear-screen
74           Ctrl-M, CR      ed-newline
75           Ctrl-N          ed-next-history
76           Ctrl-O          ed-tty-flush-output
77           Ctrl-P          ed-prev-history
78           Ctrl-Q          ed-tty-start-output
79           Ctrl-R          ed-redisplay
80           Ctrl-S          ed-tty-stop-output
81           Ctrl-U          vi-kill-line-prev
82           Ctrl-W          ed-delete-prev-word
83           Ctrl-[, ESC     em-meta-next
84           Ctrl-\, QUIT    ed-tty-sigquit
85           Space           ed-next-char
86           #               vi-comment-out
87           $               ed-move-to-end
88           %               vi-match
89           +               ed-next-history
90           ,               vi-repeat-prev-char
91           -               ed-prev-history
92           .               vi-redo
93           /               vi-search-prev
94           0               vi-zero
95           1 to 9          ed-argument-digit
96           :               ed-command
97           ;               vi-repeat-next-char
98           ?               vi-search-next
99           @               vi-alias
100           A               vi-add-at-eol
101           B               vi-prev-big-word
102           C               vi-change-to-eol
103           D               ed-kill-line
104           E               vi-end-big-word
105           F               vi-prev-char
106           G               vi-to-history-line
107           I               vi-insert-at-bol
108           J               ed-search-next-history
109           K               ed-search-prev-history
110           N               vi-repeat-search-prev
111           O               ed-sequence-lead-in
112           P               vi-paste-prev
113           R               vi-replace-mode
114           S               vi-substitute-line
115           T               vi-to-prev-char
116           U               vi-undo-line
117           W               vi-next-big-word
118           X               ed-delete-prev-char
119           Y               vi-yank-end
120           [               ed-sequence-lead-in
121           ^               ed-move-to-beg
122           _               vi-history-word
123           a               vi-add
124           b               vi-prev-word
125           c               vi-change-meta
126           d               vi-delete-meta
127           e               vi-end-word
128           f               vi-next-char
129           h               ed-prev-char
130           i               vi-insert
131           j               ed-next-history
132           k               ed-prev-history
133           l               ed-next-char
134           n               vi-repeat-search-next
135           p               vi-paste-next
136           r               vi-replace-char
137           s               vi-substitute-char
138           t               vi-to-next-char
139           u               vi-undo
140           v               vi-histedit
141           w               vi-next-word
142           x               ed-delete-next-char
143           y               vi-yank
144           |               vi-to-column
145           ~               vi-change-case
146           Ctrl-?, DEL     ed-delete-prev-char
147           Meta-O          ed-sequence-lead-in
148           Meta-[          ed-sequence-lead-in
149
150     In emacs mode, input characters are bound to the following editor com‐
151     mands by default:
152
153           0 to 9          ed-digit
154           Ctrl-@, NUL     em-set-mark
155           Ctrl-A          ed-move-to-beg
156           Ctrl-B          ed-prev-char
157           Ctrl-C, INT     ed-tty-sigint
158           Ctrl-D, EOF     em-delete-or-list
159           Ctrl-E          ed-move-to-end
160           Ctrl-F          ed-next-char
161           Ctrl-H, BS      em-delete-prev-char
162           Ctrl-J, LF      ed-newline
163           Ctrl-K          ed-kill-line
164           Ctrl-L, FF      ed-clear-screen
165           Ctrl-M, CR      ed-newline
166           Ctrl-N          ed-next-history
167           Ctrl-O          ed-tty-flush-output
168           Ctrl-P          ed-prev-history
169           Ctrl-Q          ed-tty-start-output
170           Ctrl-R          ed-redisplay
171           Ctrl-S          ed-tty-stop-output
172           Ctrl-T          ed-transpose-chars
173           Ctrl-U          ed-kill-line
174           Ctrl-V          ed-quoted-insert
175           Ctrl-W          em-kill-region
176           Ctrl-X          ed-sequence-lead-in
177           Ctrl-Y          em-yank
178           Ctrl-Z, TSTP    ed-tty-sigtstp
179           Ctrl-[, ESC     em-meta-next
180           Ctrl-\, QUIT    ed-tty-sigquit
181           Ctrl-]          ed-tty-dsusp
182           Ctrl-?, DEL     em-delete-prev-char
183           Ctrl-Meta-H     ed-delete-prev-word
184           Ctrl-Meta-L     ed-clear-screen
185           Ctrl-Meta-_     em-copy-prev-word
186           Meta-0 to 9     ed-argument-digit
187           Meta-B          ed-prev-word
188           Meta-C          em-capitol-case
189           Meta-D          em-delete-next-word
190           Meta-F          em-next-word
191           Meta-L          em-lower-case
192           Meta-N          ed-search-next-history
193           Meta-O          ed-sequence-lead-in
194           Meta-P          ed-search-prev-history
195           Meta-U          em-upper-case
196           Meta-W          em-copy-region
197           Meta-X          ed-command
198           Meta-[          ed-sequence-lead-in
199           Meta-b          ed-prev-word
200           Meta-c          em-capitol-case
201           Meta-d          em-delete-next-word
202           Meta-f          em-next-word
203           Meta-l          em-lower-case
204           Meta-n          ed-search-next-history
205           Meta-p          ed-search-prev-history
206           Meta-u          em-upper-case
207           Meta-w          em-copy-region
208           Meta-x          ed-command
209           Ctrl-Meta-?     ed-delete-prev-word
210
211     The remaining ascii(7) characters in the range 0x20 to 0x7e are bound to
212     ed-insert.
213
214     If standard output is not connected to a terminal device or el_set(3) was
215     used to set EL_EDITMODE to 0, all input character bindings are disabled
216     and all characters typed are appended to the edit buffer.  In that case,
217     the edit buffer is returned to the program after a newline or carriage
218     return character is typed, or after the first character typed if
219     el_set(3) was used to set EL_UNBUFFERED to non-zero.
220
221   Editor commands
222     Most editor commands accept an optional argument.  The argument is
223     entered by prefixing the editor command with one or more of the editor
224     commands ed-argument-digit, ed-digit, em-universal-argument, or vi-zero.
225     When an argument is not provided, it defaults to 1.  For most editor com‐
226     mands, the effect of an argument is to repeatedly execute the command
227     that number of times.
228
229     When talking about a character string from a left character to a right
230     character, the left character is included in the string, while the right
231     character is not included.
232
233     If an editor command causes an error, the input character is discarded,
234     no action occurs, and the terminal bell is rung.  In case of a non-fatal
235     error, the terminal bell is also rung, but the editor command takes
236     effect anyway.
237
238     In the following list, the default key bindings are listed after each
239     editor command.
240
241     ed-argument-digit (vi command: 1 to 9; emacs: Meta-0 to Meta-9)
242           If in argument input mode, append the input digit to the argument
243           being read.  Otherwise, switch to argument input mode and use the
244           input digit as the most significant digit of the argument.  It is
245           an error if the input character is not a digit or if the existing
246           argument is already greater than a million.
247
248     ed-clear-screen (vi command: Ctrl-L; emacs: Ctrl-L, Ctrl-Meta-L)
249           Clear the screen and display the edit buffer at the top.  Ignore
250           any argument.
251
252     ed-command (vi command: ‘:’; emacs: Meta-X, Meta-x)
253           Read a line from the terminal bypassing the normal line editing
254           functionality and execute that line as an editrc(5) builtin com‐
255           mand.  If in vi command mode, also switch back to vi insert mode.
256           Ignore any argument.
257
258     ed-delete-next-char (vi command: x)
259           Delete the character at the cursor position.  With an argument,
260           delete that number of characters.  In emacs mode, it is an error if
261           the cursor is at the end of the edit buffer.  In vi mode, the last
262           character in the edit buffer is deleted in that case, and it is an
263           error if the buffer is empty.
264
265     ed-delete-prev-char (vi command: X, Ctrl-H, BS, Ctrl-?, DEL)
266           Delete the character to the left of the cursor position.  With an
267           argument, delete that number of characters.  It is an error if the
268           cursor is at the beginning of the edit buffer.
269
270     ed-delete-prev-word (vi: Ctrl-W; emacs: Ctrl-Meta-H, Ctrl-Meta-?)
271           Move to the left to the closest beginning of a word, delete the
272           string from that position to the cursor, and save it to the cut
273           buffer.  With an argument, delete that number of words.  It is an
274           error if the cursor is at the beginning of the edit buffer.
275
276     ed-digit (emacs: 0 to 9)
277           If in argument input mode, append the input digit to the argument
278           being read.  Otherwise, call ed-insert.  It is an error if the
279           input character is not a digit or if the existing argument is
280           already greater than a million.
281
282     ed-end-of-file (not bound by default)
283           Discard the edit buffer and indicate end of file to the program.
284           Ignore any argument.
285
286     ed-ignore (various)
287           Discard the input character and do nothing.
288
289     ed-insert (vi input: almost all; emacs: printable characters)
290           In insert mode, insert the input character left of the cursor posi‐
291           tion.  In replace mode, overwrite the character at the cursor and
292           move the cursor to the right by one character position.  Accept an
293           argument to do this repeatedly.  It is an error if the input char‐
294           acter is the NUL character (Ctrl-@).  Failure to enlarge the edit
295           buffer also results in an error.
296
297     ed-kill-line (vi command: D, Ctrl-K; emacs: Ctrl-K, Ctrl-U)
298           Delete the string from the cursor position to the end of the line
299           and save it to the cut buffer.  Ignore any argument.
300
301     ed-move-to-beg (vi command: ^, Ctrl-A; emacs: Ctrl-A)
302           In vi mode, move the cursor to the first non-space character in the
303           edit buffer.  In emacs mode, move the cursor to the beginning of
304           the edit buffer.  Ignore any argument.  Can be used as a movement
305           command after vi_change_meta, vi_delete_meta, or vi_yank.
306
307     ed-move-to-end (vi command: $, Ctrl-E; emacs: Ctrl-E)
308           Move the cursor to the end of the edit buffer.  Ignore any argu‐
309           ment.  Can be used as a movement command after vi_change_meta,
310           vi_delete_meta, or vi_yank.
311
312     ed-newline (all modes: Ctrl-J, LF, Ctrl-M, CR)
313           Append a newline character to the edit buffer and return the edit
314           buffer to the program.  Ignore any argument.
315
316     ed-next-char (vi command: Space, l; emacs: Ctrl-F)
317           Move the cursor one character position to the right.  With an argu‐
318           ment, move by that number of characters.  Can be used as a movement
319           command after vi_change_meta, vi_delete_meta, or vi_yank.  It is an
320           error if the cursor is already at the end of the edit buffer.
321
322     ed-next-history (vi command: j, +, Ctrl-N; emacs: Ctrl-N)
323           Replace the edit buffer with the next history line.  That line is
324           older than the current line.  With an argument, go forward by that
325           number of history lines.  It is a non-fatal error to advance by
326           more lines than are available.
327
328     ed-next-line (not bound by default)
329           Move the cursor down one line.  With an argument, move down by that
330           number of lines.  It is an error if the edit buffer does not con‐
331           tain enough newline characters to the right of the cursor position.
332
333     ed-prev-char (vi command: h; emacs: Ctrl-B)
334           Move the cursor one character position to the left.  With an argu‐
335           ment, move by that number of characters.  Can be used as a movement
336           command after vi_change_meta, vi_delete_meta, or vi_yank.  It is an
337           error if the cursor is already at the beginning of the edit buffer.
338
339     ed-prev-history (vi command: k, -, Ctrl-P; emacs: Ctrl-P)
340           Replace the edit buffer with the previous history line.  That line
341           is newer than the current line.  With an argument, go back by that
342           number of lines.  It is a non-fatal error to back up by more lines
343           than are available.
344
345     ed-prev-line (not bound by default)
346           Move the cursor up one line.  With an argument, move up by that
347           number of lines.  It is an error if the edit buffer does not con‐
348           tain enough newline characters to the left of the cursor position.
349
350     ed-prev-word (emacs: Meta-B, Meta-b)
351           Move the cursor to the left to the closest beginning of a word.
352           With an argument, repeat that number of times.  Can be used as a
353           movement command after vi_change_meta, vi_delete_meta, or vi_yank.
354           It is an error if the cursor is already at the beginning of the
355           edit buffer.
356
357     ed-quoted-insert (vi insert, emacs: Ctrl-V)
358           Read one character from the terminal bypassing the normal line
359           editing functionality and call ed-insert on it.  If trying to read
360           the character returns end of file or an error, call ed-end-of-file
361           instead.
362
363     ed-redisplay (vi command, emacs: Ctrl-R)
364           Redisplay everything.  Ignore any argument.
365
366     ed-search-next-history (vi command: J; emacs: Meta-N, Meta-n)
367           Replace the edit buffer with the next matching history entry.
368
369     ed-search-prev-history (vi command: K; emacs: Meta-P, Meta-p)
370           Replace the edit buffer with the previous matching history entry.
371
372     ed-sequence-lead-in (vi cmd: O, [; emacs: Ctrl-X; both: Meta-O, Meta-[)
373           Call a macro.  See the section about Macros below for details.
374
375     ed-start-over (not bound by default)
376           Discard the contents of the edit buffer and start from scratch.
377           Ignore any argument.
378
379     ed-transpose-chars (emacs: Ctrl-T)
380           Exchange the character at the cursor position with the one to the
381           left of it and move the cursor to the character to the right of the
382           two exchanged characters.  Ignore any argument.  It is an error if
383           the cursor is at the beginning of the edit buffer or if the edit
384           buffer contains less than two characters.
385
386     ed-unassigned (all characters not listed)
387           This editor command always results in an error.
388
389     em-capitol-case (emacs: Meta-C, Meta-c)
390           Capitalize the string from the cursor to the end of the current
391           word.  That is, if it contains at least one alphabetic character,
392           convert the first alphabetic character to upper case, and convert
393           all characters to the right of it to lower case.  In any case, move
394           the cursor to the next character after the end of the current word.
395
396     em-copy-prev-word (emacs: Ctrl-Meta-_)
397           Copy the string from the beginning of the current word to the cur‐
398           sor and insert it to the left of the cursor.  Move the cursor to
399           the character after the inserted string.  It is an error if the
400           cursor is at the beginning of the edit buffer.
401
402     em-copy-region (emacs: Meta-W, Meta-w)
403           Copy the string from the cursor to the mark to the cut buffer.  It
404           is an error if the mark is not set.
405
406     em-delete-next-word (emacs: Meta-D, Meta-d)
407           Delete the string from the cursor to the end of the current word
408           and save it to the cut buffer.  It is an error if the cursor is at
409           the end of the edit buffer.
410
411     em-delete-or-list (emacs: Ctrl-D, EOF)
412           If the cursor is not at the end of the line, delete the character
413           at the cursor.  If the edit buffer is empty, indicate end of file
414           to the program.  It is an error if the cursor is at the end of the
415           edit buffer and the edit buffer is not empty.
416
417     em-delete-prev-char (emacs: Ctrl-H, BS, Ctrl-?, DEL)
418           Delete the character to the left of the cursor.  It is an error if
419           the cursor is at the beginning of the edit buffer.
420
421     em-exchange-mark (not bound by default)
422           Exchange the cursor and the mark.
423
424     em-gosmacs-transpose (not bound by default)
425           Exchange the two characters to the left of the cursor.  It is an
426           error if the cursor is on the first or second character of the edit
427           buffer.
428
429     em-inc-search-next (not bound by default)
430           Emacs incremental next search.
431
432     em-inc-search-prev (not bound by default)
433           Emacs incremental reverse search.
434
435     em-kill-line (not bound by default)
436           Delete the entire contents of the edit buffer and save it to the
437           cut buffer.
438
439     em-kill-region (emacs: Ctrl-W)
440           Delete the string from the cursor to the mark and save it to the
441           cut buffer.  It is an error if the mark is not set.
442
443     em-lower-case (emacs: Meta-L, Meta-l)
444           Convert the characters from the cursor to the end of the current
445           word to lower case.
446
447     em-meta-next (vi command, emacs: Ctrl-[, ESC)
448           Set the bit 0x80 on the next character typed.  Unless the resulting
449           code point is printable, holding down the ‘Meta-’ key while typing
450           that character is a simpler way to achieve the same effect.
451
452     em-next-word (Meta-F, Meta-f)
453           Move the cursor to the end of the current word.  Can be used as a
454           movement command after vi_change_meta, vi_delete_meta, or vi_yank.
455           It is an error if the cursor is already at the end of the edit buf‐
456           fer.
457
458     em-set-mark (emacs: Ctrl-Q, NUL)
459           Set the mark at the current cursor position.
460
461     em-toggle-overwrite (not bound by default)
462           Switch from insert to overwrite mode or vice versa.
463
464     em-universal-argument (not bound by default)
465           If in argument input mode, multiply the argument by 4.  Otherwise,
466           switch to argument input mode and set the argument to 4.  It is an
467           error if the existing argument is already greater than a million.
468
469     em-upper-case (emacs: Meta-U, Meta-u)
470           Convert the characters from the cursor to the end of the current
471           word to upper case.
472
473     em-yank (emacs: Ctrl-Y)
474           Paste the cut buffer to the left of the cursor.
475
476     vi-add (vi command: a)
477           Switch to vi insert mode.  Unless the cursor is already at the end
478           of the edit buffer, move it one character position to the right.
479
480     vi-add-at-eol (vi command: A)
481           Switch to vi insert mode and move the cursor to the end of the edit
482           buffer.
483
484     vi-alias (vi command: @)
485           If an alias function was defined by calling the el_set(3) or
486           el_wset(3) function with the argument EL_ALIAS_TEXT, read one char‐
487           acter from the terminal bypassing the normal line editing function‐
488           ality, call the alias function passing the argument that was speci‐
489           fied with EL_ALIAS_TEXT as the first argument and the character
490           read, with an underscore prepended, as the second argument, and
491           pass the string returned from the alias function to el_wpush(3).
492           It is an error if no alias function is defined or if trying to read
493           the character results in end of file or an error.
494
495     vi-change-case (vi command: ~)
496           Change the case of the character at the cursor and move the cursor
497           one character position to the right.  It is an error if the cursor
498           is already at the end of the edit buffer.
499
500     vi-change-meta (vi command: c)
501           Delete the string from the cursor to the position specified by the
502           following movement command and save a copy of it to the cut buffer.
503           When given twice in a row, instead delete the whole contents of the
504           edit buffer and save a copy of it to the cut buffer.  In either
505           case, switch to vi insert mode after that.
506
507     vi-change-to-eol (vi command: C)
508           Delete the string from the cursor position to the end of the line
509           and save it to the cut buffer, then switch to vi insert mode.
510
511     vi-command-mode (vi insert: Ctrl-[, ESC)
512           Discard pending actions and arguments and switch to vi command
513           mode.  Unless the cursor is already at the beginning of the edit
514           buffer, move it to the left by one character position.
515
516     vi-comment-out (vi command: #)
517           Insert a ‘#’ character at the beginning of the edit buffer and
518           return the edit buffer to the program.
519
520     vi-delete-meta (vi command: d)
521           Delete the string from the cursor to the position specified by the
522           following movement command and save a copy of it to the cut buffer.
523           When given twice in a row, instead delete the whole contents of the
524           edit buffer and save a copy of it to the cut buffer.
525
526     vi-delete-prev-char (vi insert: Ctrl-H, BS, Ctrl-?, DEL)
527           Delete the character to the left of the cursor.  It is an error if
528           the cursor is already at the beginning of the edit buffer.
529
530     vi-end-big-word (vi command: E)
531           Move the cursor to the end of the current space delimited word.
532           Can be used as a movement command after vi_change_meta,
533           vi_delete_meta, or vi_yank.  It is an error if the cursor is
534           already at the end of the edit buffer.
535
536     vi-end-word (vi command: e)
537           Move the cursor to the end of the current word.  Can be used as a
538           movement command after vi_change_meta, vi_delete_meta, or vi_yank.
539           It is an error if the cursor is already at the end of the edit buf‐
540           fer.
541
542     vi-history-word (vi command: _)
543           Insert the first word from the most recent history entry after the
544           cursor, move the cursor after to the character after the inserted
545           word, and switch to vi insert mode.  It is an error if there is no
546           history entry or the most recent history entry is empty.
547
548     vi-insert (vi command: i)
549           Enter insert mode.
550
551     vi-insert-at-bol (vi command: I)
552           Move the cursor to the beginning of the edit buffer and switch to
553           vi insert mode.
554
555     vi-kill-line-prev (vi: Ctrl-U)
556           Delete the string from the beginning of the edit buffer to the cur‐
557           sor and save it to the cut buffer.
558
559     vi-list-or-eof (vi insert: Ctrl-D, EOF)
560           If the edit buffer is empty, indicate end of file to the program.
561           It is an error if the edit buffer is not empty.
562
563     vi-match (vi command: %)
564           Consider opening and closing parentheses, braces, and brackets as
565           delimiters.  If the cursor is not at a delimiter, move it to the
566           right until it gets to one, then move it to the matching delimiter.
567           Can be used as a movement command after vi_change_meta,
568           vi_delete_meta, or vi_yank.  It is an error if there is no delim‐
569           iter at the cursor or in the string to the right of the cursor, or
570           if the first such delimiter has no matching delimiter.
571
572     vi-next-big-word (vi command: W)
573           Move the cursor to the right to the beginning of the next space
574           delimited word.  Can be used as a movement command after
575           vi_change_meta, vi_delete_meta, or vi_yank.  It is an error if the
576           cursor is already at the end of the edit buffer or on its last
577           character.
578
579     vi-next-char (vi command: f)
580           Read one character from the terminal bypassing the normal line
581           editing functionality and move the cursor to the right to the next
582           instance of that character in the edit buffer.  Can be used as a
583           movement command after vi_change_meta, vi_delete_meta, or vi_yank.
584           If trying to read the character results in end of file or an error,
585           call ed-end-of-file instead.  It is an error if the character is
586           not found searching to the right in the edit buffer.
587
588     vi-next-word (vi command: w)
589           Move the cursor to the right to the beginning of the next word.
590           Can be used as a movement command after vi_change_meta,
591           vi_delete_meta, or vi_yank.  It is an error if the cursor is
592           already at the end of the edit buffer or on its last character.
593
594     vi-paste-next (vi command: p)
595           Insert a copy of the cut buffer to the right of the cursor.  It is
596           an error if the cut buffer is empty.
597
598     vi-paste-prev (vi command: P)
599           Insert a copy of the cut buffer to the left of the cursor.  It is
600           an error if the cut buffer is empty.
601
602     vi-prev-big-word (vi command: B)
603           Move the cursor to the left to the next beginning of a space delim‐
604           ited word.  Can be used as a movement command after vi_change_meta,
605           vi_delete_meta, or vi_yank.  It is an error if the cursor is
606           already at the beginning of the edit buffer.
607
608     vi-prev-char (vi command: F)
609           Read one character from the terminal bypassing the normal line
610           editing functionality and move the cursor to the left to the next
611           instance of that character in the edit buffer.  Can be used as a
612           movement command after vi_change_meta, vi_delete_meta, or vi_yank.
613           If trying to read the character results in end of file or an error,
614           call ed-end-of-file instead.  It is an error if the character is
615           not found searching to the left in the edit buffer.
616
617     vi-prev-word (vi command: b)
618           Move the cursor to the left to the next beginning of a word.  Can
619           be used as a movement command after vi_change_meta, vi_delete_meta,
620           or vi_yank.  It is an error if the cursor is already at the begin‐
621           ning of the edit buffer.
622
623     vi-redo (vi command: ‘.’)
624           Redo the last non-motion command.
625
626     vi-repeat-next-char (vi command: ‘;’)
627           Repeat the most recent character search in the same search direc‐
628           tion.  Can be used as a movement command after vi_change_meta,
629           vi_delete_meta, or vi_yank.
630
631     vi-repeat-prev-char (vi command: ‘,’)
632           Repeat the most recent character search in the opposite search
633           direction.  Can be used as a movement command after vi_change_meta,
634           vi_delete_meta, or vi_yank.
635
636     vi-repeat-search-next (vi command: n)
637           Repeat the most recent history search in the same search direction.
638
639     vi-repeat-search-prev (vi command: N)
640           Repeat the most recent history search in the opposite search direc‐
641           tion.
642
643     vi-replace-char (vi command: r)
644           Switch to vi replace mode, and automatically switch back to vi com‐
645           mand mode after the next character typed.  See ed-insert for a
646           description of replace mode.  It is an error if the cursor is at
647           the end of the edit buffer.
648
649     vi-replace-mode (vi command: R)
650           Switch to vi replace mode.  This is a variant of vi insert mode;
651           see ed-insert for the difference.
652
653     vi-search-next (vi command: ?)
654           Replace the edit buffer with the next matching history entry.
655
656     vi-search-prev (vi command: /)
657           Replace the edit buffer with the previous matching history entry.
658
659     vi-substitute-char (vi command: s)
660           Delete the character at the cursor and switch to vi insert mode.
661
662     vi-substitute-line (vi command: S)
663           Delete the entire contents of the edit buffer, save a copy of it in
664           the cut buffer, and enter vi insert mode.
665
666     vi-to-column (vi command: |)
667           Move the cursor to the column specified as the argument.  Can be
668           used as a movement command after vi_change_meta, vi_delete_meta, or
669           vi_yank.
670
671     vi-to-history-line (vi command: G)
672           Replace the edit buffer with the specified history entry.
673
674     vi-to-next-char (vi command: t)
675           Read one character from the terminal bypassing the normal line
676           editing functionality and move the cursor to the right to the char‐
677           acter before the next instance of that character in the edit buf‐
678           fer.  Can be used as a movement command after vi_change_meta,
679           vi_delete_meta, or vi_yank.  If trying to read the character
680           results in end of file or an error, call ed-end-of-file instead.
681           It is an error if the character is not found searching to the right
682           in the edit buffer.
683
684     vi-to-prev-char (vi command: T)
685           Read one character from the terminal bypassing the normal line
686           editing functionality and move the cursor to the left to the char‐
687           acter after the next instance of that character in the edit buffer.
688           Can be used as a movement command after vi_change_meta,
689           vi_delete_meta, or vi_yank.  If trying to read the character
690           results in end of file or an error, call ed-end-of-file instead.
691           It is an error if the character is not found searching to the left
692           in the edit buffer.
693
694     vi-undo (vi command: u)
695           Undo the last change.
696
697     vi-undo-line (vi command: U)
698           Undo all changes to the edit buffer.
699
700     vi-yank (vi command: y)
701           Copy the string from the cursor to the position specified by the
702           following movement command to the cut buffer.  When given twice in
703           a row, instead copy the whole contents of the edit buffer to the
704           cut buffer.
705
706     vi-yank-end (vi command: Y)
707           Copy the string from the cursor to the end of the edit buffer to
708           the cut buffer.
709
710     vi-zero (vi command: 0)
711           If in argument input mode, multiply the argument by ten.  Other‐
712           wise, move the cursor to the beginning of the edit buffer.  Can be
713           used as a movement command after vi_change_meta, vi_delete_meta, or
714           vi_yank.
715
716   Macros
717     If an input character is bound to the editor command ed-sequence-lead-in,
718     editline attempts to call a macro.  If the input character by itself
719     forms the name of a macro, that macro is executed.  Otherwise, additional
720     input characters are read until the string read forms the name of a
721     macro, in which case that macro is executed, or until the string read
722     matches the beginning of none of the existing macro names, in which case
723     the string including the final, mismatching character is discarded and
724     the terminal bell is rung.
725
726     There are two kinds of macros.  Command macros execute a single editor
727     command.  Keyboard macros return a string of characters that is appended
728     as a new line to the Input Queue.
729
730     The following command macros are defined by default in vi command mode
731     and in emacs mode:
732
733           Esc [ A, Esc O A    ed-prev-history
734           Esc [ B, Esc O B    ed-next-history
735           Esc [ C, Esc O C    ed-next-char
736           Esc [ D, Esc O D    ed-prev-char
737           Esc [ F, Esc O F    ed-move-to-end
738           Esc [ H, Esc O H    ed-move-to-beg
739
740     In vi command mode, they are also defined by default without the initial
741     escape character.
742
743     In addition, the editline library tries to bind the strings generated by
744     the arrow keys as reported by the terminfo(5) database to these editor
745     commands, unless that would clobber user settings.
746
747     In emacs mode, the two-character string “Ctrl-X Ctrl-X” is bound to the
748     em-exchange-mark editor command.
749
750   Input Queue
751     The editline library maintains an input queue operated in FIFO mode.
752     Whenever it needs an input character, it takes the first character from
753     the first line of the input queue.  When the queue is empty, it reads
754     from the terminal.
755
756     A line can be appended to the end of the input queue in several ways:
757
758           -   By calling one of the keyboard Macros.
759
760           -   By calling the editor command vi-redo.
761
762           -   By calling the editor command vi-alias.
763
764           -   By pressing a key in emacs incremental search mode that doesn't
765               have a special meaning in that mode but returns to normal emacs
766               mode.
767
768           -   If an application program directly calls the functions
769               el_push(3) or el_wpush(3), it can provide additional, program-
770               specific ways of appending to the input queue.
771

SEE ALSO

773     mg(1), vi(1), editline(3), el_wgets(3), el_wpush(3), el_wset(3),
774     editrc(5)
775

HISTORY

777     This manual page first appeared in OpenBSD 6.0 and NetBSD 8.
778

AUTHORS

780     This manual page was written by Ingo Schwarze <schwarze@openbsd.org>.
781
782BSD                               May 7, 2016                              BSD
Impressum