EDITLINE(7)

๐Ÿ’… NAME ๐Ÿ’…

okay so bestie, this is editline(7) โ€” the line editing user interface. yes, the whole vibe of typing into a terminal and having your keys actually do stuff. periodt. ๐ŸŽ€


โœจ DESCRIPTION โœจ

So when a program that's using the editline(3) library wants an input string, it calls el_wgets(3) and starts reading characters from the terminal. And like โ€” invalid input bytes that don't form characters? silently discarded. gone. not invited to the party. ๐Ÿ’€

For each character read, one editor command is executed. One char, one command, that's the rule. The mapping from input characters to editor commands depends on the editing mode, and there are three of them:

  • vi insert mode
  • vi command mode
  • emacs mode

Default is vi insert mode. The program can switch the default over to emacs mode using the el_set(3) or el_parse(3) functions, and you can switch to emacs mode either in the editrc(5) configuration file or interactively with the ed-command editor command โ€” in all three cases you're executing the bind -e builtin command. slay. โœจ

If trying to read from the terminal results in end of file or an error, the library signals end of file to the program and does not return a string. no string for you, bestie. ๐Ÿ˜ญ


๐Ÿฆ‹ Input character bindings ๐Ÿฆ‹

All the default bindings described below can be overridden by individual programs, and can also be changed with the editrc(5) bind builtin command. so like, nothing here is forever. ๐Ÿ’…

In the following tables, Ctrl- indicates a character with the bit 0x40 flipped, and Meta- indicates a character with the bit 0x80 set. In vi insert mode and in emacs mode, all Meta-characters considered printable by the current locale(1) are bound to ed-insert instead of to the editor command listed below. Consequently, in UTF-8 mode, most of the Meta-characters are not directly accessible because their code points are occupied by printable Unicode characters โ€” and Meta-characters are usually input using the em-meta-next editor command. ๐Ÿ™ˆ

For example, to enter Meta-B in order to call the ed-prev-word editor command in emacs mode, call em-meta-next by pressing and releasing the escape key (or equivalently, Ctrl+[), then press and release the B key. If you have configured a Meta-key on your keyboard โ€” for example with

setxkbmap -option altwin:left_meta_win

โ€” then the Ctrl-Meta-characters are directly accessible. For example, to enter Ctrl-Meta-H in order to call the ed-delete-prev-word editor command in emacs mode, hold down the keys Ctrl, Meta, and H at the same time. Alternatively, press and release the escape key, then press and release Ctrl-H. multiple paths to the same glow-up, honestly. ๐ŸŒˆ

๐ŸŒธ In vi input mode

Input characters are bound to these editor commands by default:

  • Ctrl-D, EOF โ†’ vi-list-or-eof
  • Ctrl-H, BS โ†’ vi-delete-prev-char
  • Ctrl-J, LF โ†’ ed-newline
  • Ctrl-M, CR โ†’ ed-newline
  • Ctrl-Q โ†’ ed-tty-start-output
  • Ctrl-S โ†’ ed-tty-stop-output
  • Ctrl-U โ†’ vi-kill-line-prev
  • Ctrl-V โ†’ ed-quoted-insert
  • Ctrl-W โ†’ ed-delete-prev-word
  • Ctrl-[, ESC โ†’ vi-command-mode
  • Ctrl-\, QUIT โ†’ ed-tty-sigquit
  • Ctrl-?, DEL โ†’ vi-delete-prev-char

All other input characters except the NUL character (Ctrl-@) are bound to ed-insert. ๐Ÿ’–

๐Ÿงš In vi command mode

Input characters are bound to these editor commands by default:

  • Ctrl-A โ†’ ed-move-to-beg
  • Ctrl-C, INT โ†’ ed-tty-sigint
  • Ctrl-E โ†’ ed-move-to-end
  • Ctrl-H, BS โ†’ ed-delete-prev-char
  • Ctrl-J, LF โ†’ ed-newline
  • Ctrl-K โ†’ ed-kill-line
  • Ctrl-L, FF โ†’ ed-clear-screen
  • Ctrl-M, CR โ†’ ed-newline
  • Ctrl-N โ†’ ed-next-history
  • Ctrl-O โ†’ ed-tty-flush-output
  • Ctrl-P โ†’ ed-prev-history
  • Ctrl-Q โ†’ ed-tty-start-output
  • Ctrl-R โ†’ ed-redisplay
  • Ctrl-S โ†’ ed-tty-stop-output
  • Ctrl-U โ†’ vi-kill-line-prev
  • Ctrl-W โ†’ ed-delete-prev-word
  • Ctrl-[, ESC โ†’ em-meta-next
  • Ctrl-\, QUIT โ†’ ed-tty-sigquit
  • Space โ†’ ed-next-char
  • # โ†’ vi-comment-out
  • $ โ†’ ed-move-to-end
  • % โ†’ vi-match
  • + โ†’ ed-next-history
  • , โ†’ vi-repeat-prev-char
  • - โ†’ ed-prev-history
  • . โ†’ vi-redo
  • / โ†’ vi-search-prev
  • 0 โ†’ vi-zero
  • 1 to 9 โ†’ ed-argument-digit
  • : โ†’ ed-command
  • ; โ†’ vi-repeat-next-char
  • ? โ†’ vi-search-next
  • @ โ†’ vi-alias
  • A โ†’ vi-add-at-eol
  • B โ†’ vi-prev-big-word
  • C โ†’ vi-change-to-eol
  • D โ†’ ed-kill-line
  • E โ†’ vi-end-big-word
  • F โ†’ vi-prev-char
  • G โ†’ vi-to-history-line
  • I โ†’ vi-insert-at-bol
  • J โ†’ ed-search-next-history
  • K โ†’ ed-search-prev-history
  • N โ†’ vi-repeat-search-prev
  • O โ†’ ed-sequence-lead-in
  • P โ†’ vi-paste-prev
  • R โ†’ vi-replace-mode
  • S โ†’ vi-substitute-line
  • T โ†’ vi-to-prev-char
  • U โ†’ vi-undo-line
  • W โ†’ vi-next-big-word
  • X โ†’ ed-delete-prev-char
  • Y โ†’ vi-yank-end
  • [ โ†’ ed-sequence-lead-in
  • ^ โ†’ ed-move-to-beg
  • _ โ†’ vi-history-word
  • a โ†’ vi-add
  • b โ†’ vi-prev-word
  • c โ†’ vi-change-meta
  • d โ†’ vi-delete-meta
  • e โ†’ vi-end-word
  • f โ†’ vi-next-char
  • h โ†’ ed-prev-char
  • i โ†’ vi-insert
  • j โ†’ ed-next-history
  • k โ†’ ed-prev-history
  • l โ†’ ed-next-char
  • n โ†’ vi-repeat-search-next
  • p โ†’ vi-paste-next
  • r โ†’ vi-replace-char
  • s โ†’ vi-substitute-char
  • t โ†’ vi-to-next-char
  • u โ†’ vi-undo
  • v โ†’ vi-histedit
  • w โ†’ vi-next-word
  • x โ†’ ed-delete-next-char
  • y โ†’ vi-yank
  • | โ†’ vi-to-column
  • ~ โ†’ vi-change-case
  • Ctrl-?, DEL โ†’ ed-delete-prev-char
  • Meta-O โ†’ ed-sequence-lead-in
  • Meta-[ โ†’ ed-sequence-lead-in

๐Ÿ’œ In emacs mode

Input characters are bound to these editor commands by default:

  • 0 to 9 โ†’ ed-digit
  • Ctrl-@, NUL โ†’ em-set-mark
  • Ctrl-A โ†’ ed-move-to-beg
  • Ctrl-B โ†’ ed-prev-char
  • Ctrl-C, INT โ†’ ed-tty-sigint
  • Ctrl-D, EOF โ†’ em-delete-or-list
  • Ctrl-E โ†’ ed-move-to-end
  • Ctrl-F โ†’ ed-next-char
  • Ctrl-H, BS โ†’ em-delete-prev-char
  • Ctrl-J, LF โ†’ ed-newline
  • Ctrl-K โ†’ ed-kill-line
  • Ctrl-L, FF โ†’ ed-clear-screen
  • Ctrl-M, CR โ†’ ed-newline
  • Ctrl-N โ†’ ed-next-history
  • Ctrl-O โ†’ ed-tty-flush-output
  • Ctrl-P โ†’ ed-prev-history
  • Ctrl-Q โ†’ ed-tty-start-output
  • Ctrl-R โ†’ ed-redisplay
  • Ctrl-S โ†’ ed-tty-stop-output
  • Ctrl-T โ†’ ed-transpose-chars
  • Ctrl-U โ†’ ed-kill-line
  • Ctrl-V โ†’ ed-quoted-insert
  • Ctrl-W โ†’ em-kill-region
  • Ctrl-X โ†’ ed-sequence-lead-in
  • Ctrl-Y โ†’ em-yank
  • Ctrl-Z, TSTP โ†’ ed-tty-sigtstp
  • Ctrl-[, ESC โ†’ em-meta-next
  • Ctrl-\, QUIT โ†’ ed-tty-sigquit
  • Ctrl-] โ†’ ed-tty-dsusp
  • Ctrl-?, DEL โ†’ em-delete-prev-char
  • Ctrl-Meta-H โ†’ ed-delete-prev-word
  • Ctrl-Meta-L โ†’ ed-clear-screen
  • Ctrl-Meta-_ โ†’ em-copy-prev-word
  • Meta-0 to 9 โ†’ ed-argument-digit
  • Meta-B โ†’ ed-prev-word
  • Meta-C โ†’ em-capitol-case
  • Meta-D โ†’ em-delete-next-word
  • Meta-F โ†’ em-next-word
  • Meta-L โ†’ em-lower-case
  • Meta-N โ†’ ed-search-next-history
  • Meta-O โ†’ ed-sequence-lead-in
  • Meta-P โ†’ ed-search-prev-history
  • Meta-U โ†’ em-upper-case
  • Meta-W โ†’ em-copy-region
  • Meta-X โ†’ ed-command
  • Meta-[ โ†’ ed-sequence-lead-in
  • Meta-b โ†’ ed-prev-word
  • Meta-c โ†’ em-capitol-case
  • Meta-d โ†’ em-delete-next-word
  • Meta-f โ†’ em-next-word
  • Meta-l โ†’ em-lower-case
  • Meta-n โ†’ ed-search-next-history
  • Meta-p โ†’ ed-search-prev-history
  • Meta-u โ†’ em-upper-case
  • Meta-w โ†’ em-copy-region
  • Meta-x โ†’ ed-command
  • Ctrl-Meta-? โ†’ ed-delete-prev-word

๐Ÿ“ the rest of the keys

The remaining ascii(7) characters in the range 0x20 to 0x7e are bound to ed-insert. that's the whole squad accounted for. ๐Ÿ‘‘

๐Ÿ”ฅ plot twist: no terminal, no bindings

If standard output is not connected to a terminal device, or el_set(3) was used to set EL_EDITMODE to 0, all input character bindings are disabled and all characters typed are appended to the edit buffer. In that case, the edit buffer is returned to the program after a newline or carriage return character is typed โ€” or after the first character typed if el_set(3) was used to set EL_UNBUFFERED to non-zero. it's giving "just take the raw text, bestie." ๐Ÿซถ


โญ Editor commands โญ

Most editor commands accept an optional argument. You enter that argument by prefixing the editor command with one or more of these:

  • ed-argument-digit
  • ed-digit
  • em-universal-argument
  • vi-zero

When an argument is not provided, it defaults to 1. For most editor commands, the effect of an argument is to repeatedly execute the command that number of times. iconic multiplier behaviour, no cap. โœจ

When talking about a character string from a left character to a right character: the left character is included in the string, while the right character is not included. (half-open range supremacy, iykyk.) ๐Ÿ’…

โš ๏ธ If an editor command causes an error, the input character is discarded, no action occurs, and the terminal bell is rung. In case of a non-fatal error, the terminal bell is also rung, but the editor command takes effect anyway. so you get the beep and the vibes. ๐Ÿ’€

In the following list, the default key bindings are listed after each editor command. ๐ŸŽ€

  • ed-argument-digit (vi command: 1 to 9; emacs: Meta-0 to Meta-9) โ€” If in argument input mode, append the input digit to the argument being read. Otherwise, switch to argument input mode and use the input digit as the most significant digit of the argument. It is an error if the input character is not a digit, or if the existing argument is already greater than a million. (one million, bestie โ€” that's the limit, don't push it.) ๐Ÿ˜ญ
  • ed-clear-screen (vi command: Ctrl-L; emacs: Ctrl-L, Ctrl-Meta-L) โ€” Clear the screen and display the edit buffer at the top. Ignores any argument. fresh slate energy โœจ
  • ed-command (vi command: :; emacs: Meta-X, Meta-x) โ€” Read a line from the terminal bypassing the normal line editing functionality, and execute that line as an editrc(5) builtin command. If in vi command mode, also switch back to vi insert mode. Ignores any argument.
  • ed-delete-next-char (vi command: x) โ€” Delete the character at the cursor position. With an argument, delete that number of characters. In emacs mode, it is an error if the cursor is at the end of the edit buffer. In vi mode, the last character in the edit buffer is deleted in that case, and it is an error if the buffer is empty. vi stays generous, emacs stays strict ๐Ÿซถ
  • ed-delete-prev-char (vi command: X, Ctrl-H, BS, Ctrl-?, DEL) โ€” Delete the character to the left of the cursor position. With an argument, delete that number of characters. It is an error if the cursor is at the beginning of the edit buffer. ๐Ÿ˜ญ
  • ed-delete-prev-word (vi: Ctrl-W; emacs: Ctrl-Meta-H, Ctrl-Meta-?) โ€” Move to the left to the closest beginning of a word, delete the string from that position to the cursor, and save it to the cut buffer. With an argument, delete that number of words. It is an error if the cursor is at the beginning of the edit buffer. cut buffer stays fed ๐Ÿ’…
  • ed-digit (emacs: 0 to 9) โ€” If in argument input mode, append the input digit to the argument being read. Otherwise, call ed-insert. It is an error if the input character is not a digit, or if the existing argument is already greater than a million.
  • ed-end-of-file (not bound by default) โ€” Discard the edit buffer and indicate end of file to the program. Ignores any argument. bye bestie ๐Ÿ‘‹
  • ed-ignore (various) โ€” Discard the input character and do nothing. literally the "seen, no response" of editor commands. ๐Ÿ™ˆ
  • ed-insert (vi input: almost all; emacs: printable characters) โ€” In insert mode, insert the input character left of the cursor position. In replace mode, overwrite the character at the cursor and move the cursor to the right by one character position. Accept an argument to do this repeatedly. It is an error if the input character is the NUL character (Ctrl-@). Failure to enlarge the edit buffer also results in an error. ๐Ÿซถ
  • ed-kill-line (vi command: D, Ctrl-K; emacs: Ctrl-K, Ctrl-U) โ€” Delete the string from the cursor position to the end of the line and save it to the cut buffer. Ignore any argument. โœ‚๏ธ
  • ed-move-to-beg (vi command: ^, Ctrl-A; emacs: Ctrl-A) โ€” In vi mode, move the cursor to the first non-space character in the edit buffer. In emacs mode, move the cursor to the beginning of the edit buffer. Ignore any argument. Can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. ๐Ÿ’…
  • ed-move-to-end (vi command: $, Ctrl-E; emacs: Ctrl-E) โ€” Move the cursor to the end of the edit buffer. Ignore any argument. Can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. โœจ
  • ed-newline (all modes: Ctrl-J, LF, Ctrl-M, CR) โ€” Append a newline character to the edit buffer and return the edit buffer to the program. Ignore any argument. ๐ŸŽ€
  • ed-next-char (vi command: Space, l; emacs: Ctrl-F) โ€” Move the cursor one character position to the right. With an argument, move by that number of characters. Can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. It is an error if the cursor is already at the end of the edit buffer. ๐Ÿ‘‰
  • ed-next-history (vi command: j, +, Ctrl-N; emacs: Ctrl-N) โ€” Replace the edit buffer with the next history line. That line is older than the current line. With an argument, go forward by that number of history lines. It is a non-fatal error to advance by more lines than are available. ๐Ÿ•ฐ๏ธ
  • ed-next-line (not bound by default) โ€” Move the cursor down one line. With an argument, move down by that number of lines. It is an error if the edit buffer does not contain enough newline characters to the right of the cursor position. ๐Ÿงš
  • ed-prev-char (vi command: h; emacs: Ctrl-B) โ€” Move the cursor one character position to the left. With an argument, move by that number of characters. Can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. It is an error if the cursor is already at the beginning of the edit buffer. ๐Ÿ‘ˆ
  • ed-prev-history (vi command: k, -, Ctrl-P; emacs: Ctrl-P) โ€” Replace the edit buffer with the previous history line. That line is newer than the current line. With an argument, go back by that number of lines. It is a non-fatal error to back up by more lines than are available. ๐ŸŒ€
  • ed-prev-line (not bound by default) โ€” Move the cursor up one line. With an argument, move up by that number of lines. It is an error if the edit buffer does not contain enough newline characters to the left of the cursor position. ๐Ÿฆ‹
  • ed-prev-word (emacs: Meta-B, Meta-b) โ€” Move the cursor to the left to the closest beginning of a word. With an argument, repeat that number of times. Can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. It is an error if the cursor is already at the beginning of the edit buffer. ๐ŸŒธ
  • ed-quoted-insert (vi insert, emacs: Ctrl-V) โ€” Read one character from the terminal bypassing the normal line editing functionality and call ed-insert on it. If trying to read the character returns end of file or an error, call ed-end-of-file instead. ๐Ÿ™ˆ
  • ed-redisplay (vi command, emacs: Ctrl-R) โ€” Redisplay everything. Ignore any argument. ๐Ÿ”ฅ
  • ed-search-next-history (vi command: J; emacs: Meta-N, Meta-n) โ€” Replace the edit buffer with the next matching history entry. ๐Ÿ”Ž
  • ed-search-prev-history (vi command: K; emacs: Meta-P, Meta-p) โ€” Replace the edit buffer with the previous matching history entry. ๐Ÿ”
  • ed-sequence-lead-in (vi cmd: O, [; emacs: Ctrl-X; both: Meta-O, Meta-[) โ€” Call a macro. See the section about Macros below for details. ๐Ÿช„
  • ed-start-over (not bound by default) โ€” Discard the contents of the edit buffer and start from scratch. Ignore any argument. ๐Ÿงผ
  • ed-transpose-chars (emacs: Ctrl-T) โ€” Exchange the character at the cursor position with the one to the left of it and move the cursor to the character to the right of the two exchanged characters. Ignore any argument. It is an error if the cursor is at the beginning of the edit buffer or if the edit buffer contains less than two characters. ๐Ÿ”„
  • ed-unassigned (all characters not listed) โ€” This editor command always results in an error. literally always ๐Ÿ’€
  • em-capitol-case (emacs: Meta-C, Meta-c) โ€” Capitalize the string from the cursor to the end of the current word. That is, if it contains at least one alphabetic character, convert the first alphabetic character to upper case, and convert all characters to the right of it to lower case. In any case, move the cursor to the next character after the end of the current word. ๐Ÿ‘‘
  • em-copy-prev-word (emacs: Ctrl-Meta-_) โ€” Copy the string from the beginning of the current word to the cursor and insert it to the left of the cursor. Move the cursor to the character after the inserted string. It is an error if the cursor is at the beginning of the edit buffer. ๐Ÿ“‹
  • em-copy-region (emacs: Meta-W, Meta-w) โ€” Copy the string from the cursor to the mark to the cut buffer. It is an error if the mark is not set. ๐ŸŽฏ
  • em-delete-next-word (emacs: Meta-D, Meta-d) โ€” Delete the string from the cursor to the end of the current word and save it to the cut buffer. It is an error if the cursor is at the end of the edit buffer. ๐Ÿ—‘๏ธ
  • em-delete-or-list (emacs: Ctrl-D, EOF) โ€” If the cursor is not at the end of the line, delete the character at the cursor. If the edit buffer is empty, indicate end of file to the program. It is an error if the cursor is at the end of the edit buffer and the edit buffer is not empty. ๐Ÿ˜ญ
  • em-delete-prev-char (emacs: Ctrl-H, BS, Ctrl-?, DEL) โ€” Delete the character to the left of the cursor. It is an error if the cursor is at the beginning of the edit buffer. โŒซ
  • em-exchange-mark (not bound by default) โ€” Exchange the cursor and the mark. ๐Ÿ”
  • em-gosmacs-transpose (not bound by default) โ€” Exchange the two characters to the left of the cursor. It is an error if the cursor is on the first or second character of the edit buffer. ๐ŸŒ€
  • em-inc-search-next (not bound by default) โ€” Emacs incremental next search. โญ๏ธ
  • em-inc-search-prev (not bound by default) โ€” Emacs incremental reverse search. โฎ๏ธ
  • em-kill-line (not bound by default) โ€” Delete the entire contents of the edit buffer and save it to the cut buffer. ๐Ÿงจ
  • em-kill-region (emacs: Ctrl-W) โ€” Delete the string from the cursor to the mark and save it to the cut buffer. It is an error if the mark is not set. ๐Ÿ’ฅ
  • em-lower-case (emacs: Meta-L, Meta-l) โ€” Convert the characters from the cursor to the end of the current word to lower case. ๐Ÿ”ก
  • em-meta-next (vi command, emacs: Ctrl-[, ESC) โ€” Set the bit 0x80 on the next character typed. Unless the resulting code point is printable, holding down the Meta- key while typing that character is a simpler way to achieve the same effect. ๐Ÿงฌ
  • em-next-word (Meta-F, Meta-f) โ€” Move the cursor to the end of the current word. Can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. It is an error if the cursor is already at the end of the edit buffer. ๐Ÿƒโ€โ™€๏ธ
  • em-set-mark (emacs: Ctrl-Q, NUL) โ€” Set the mark at the current cursor position. ๐Ÿ“
  • em-toggle-overwrite (not bound by default) โ€” Switch from insert to overwrite mode or vice versa. ๐Ÿ”€
  • em-universal-argument (not bound by default) โ€” If in argument input mode, multiply the argument by 4. Otherwise, switch to argument input mode and set the argument to 4. It is an error if the existing argument is already greater than a million. ๐Ÿ”ข
  • em-upper-case (emacs: Meta-U, Meta-u) โ€” Convert the characters from the cursor to the end of the current word to upper case. ๐Ÿ” 
  • em-yank (emacs: Ctrl-Y) โ€” Paste the cut buffer to the left of the cursor. ๐Ÿ“
  • vi-add (vi command: a) โ€” Switch to vi insert mode. Unless the cursor is already at the end of the edit buffer, move it one character position to the right. โž•
  • vi-add-at-eol (vi command: A) โ€” Switch to vi insert mode and move the cursor to the end of the edit buffer. ๐ŸŽฌ
  • vi-alias (vi command: @) โ€” If an alias function was defined by calling the el_set(3) or el_wset(3) function with the argument EL_ALIAS_TEXT, read one character from the terminal bypassing the normal line editing functionality, call the alias function passing the argument that was specified with EL_ALIAS_TEXT as the first argument and the character read, with an underscore prepended, as the second argument, and pass the string returned from the alias function to el_wpush(3). It is an error if no alias function is defined or if trying to read the character results in end of file or an error. ๐Ÿชž
  • vi-change-case (vi command: ~) โ€” Change the case of the character at the cursor and move the cursor one character position to the right. It is an error if the cursor is already at the end of the edit buffer. ๐Ÿ”ƒ
  • vi-change-meta (vi command: c) โ€” Delete the string from the cursor to the position specified by the following movement command and save a copy of it to the cut buffer. When given twice in a row, instead delete the whole contents of the edit buffer and save a copy of it to the cut buffer. In either case, switch to vi insert mode after that. ๐Ÿ› ๏ธ
  • vi-change-to-eol (vi command: C) โ€” Delete the string from the cursor position to the end of the line and save it to the cut buffer, then switch to vi insert mode. โœ‚๏ธ
  • vi-command-mode (vi insert: Ctrl-[, ESC) โ€” bestie, this one yeets your pending actions and arguments into the void and drops you back into vi command mode. And unless your cursor is already chillin' at the beginning of the edit buffer, it scooches it left by one character position. tiny little nudge ๐Ÿ’…
  • vi-comment-out (vi command: #) โ€” slaps a literal # character at the beginning of the edit buffer and hands the whole edit buffer back to the program. like "never mind, take it" โœจ
  • vi-delete-meta (vi command: d) โ€” deletes the string from the cursor all the way to wherever the following movement command lands, and saves a copy of it in the cut buffer. but when you hit it twice in a row? icon behaviour โ€” it deletes the entire contents of the edit buffer instead, and saves a copy of that in the cut buffer too. ๐Ÿซถ
  • vi-delete-prev-char (vi insert: Ctrl-H, BS, Ctrl-?, DEL) โ€” deletes the character sitting to the left of the cursor. it's an error if the cursor is already at the beginning of the edit buffer, so don't come for it ๐Ÿ˜ญ
  • vi-end-big-word (vi command: E) โ€” bounces the cursor to the end of the current space delimited word. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. it's an error if the cursor is already at the end of the edit buffer. ๐Ÿฆ‹
  • vi-end-word (vi command: e) โ€” same energy, but it moves the cursor to the end of the current word. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. it's an error if the cursor is already at the end of the edit buffer. ๐Ÿ’œ
  • vi-history-word (vi command: _) โ€” pulls the first word from the most recent history entry, drops it in after the cursor, moves the cursor to the character after the inserted word, and switches you into vi insert mode. it's an error if there's no history entry, or if the most recent history entry is empty. no vibes to steal, sorry ๐ŸŽ€
  • vi-insert (vi command: i) โ€” enter insert mode. that's it, that's the whole thing. slay ๐Ÿงš
  • vi-insert-at-bol (vi command: I) โ€” moves the cursor to the beginning of the edit buffer and switches to vi insert mode. two for one, we love efficiency ๐Ÿ‘‘
  • vi-kill-line-prev (vi: Ctrl-U) โ€” deletes the string from the beginning of the edit buffer down to the cursor and saves it to the cut buffer. โญ
  • vi-list-or-eof (vi insert: Ctrl-D, EOF) โ€” if the edit buffer is empty, it indicates end of file to the program. it's an error if the edit buffer is not empty. empty buffer only, those are the rules ๐Ÿ™ˆ
  • vi-match (vi command: %) โ€” treats opening and closing parentheses, braces, and brackets as delimiters. if the cursor isn't sitting on a delimiter, it moves right until it finds one, then jumps to the matching delimiter. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. it's an error if there's no delimiter at the cursor or in the string to the right of the cursor, or if the first such delimiter has no matching delimiter. unmatched bracket = no match, literally ๐Ÿ’€
  • vi-next-big-word (vi command: W) โ€” moves the cursor to the right, to the beginning of the next space delimited word. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. it's an error if the cursor is already at the end of the edit buffer or on its last character. ๐Ÿ˜ค
  • vi-next-char (vi command: f) โ€” reads one character from the terminal, bypassing the normal line editing functionality, then moves the cursor right to the next instance of that character in the edit buffer. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. if trying to read the character results in end of file or an error, it calls ed-end-of-file instead. it's an error if the character is not found searching to the right in the edit buffer. ๐Ÿ”ฅ
  • vi-next-word (vi command: w) โ€” moves the cursor to the right, to the beginning of the next word. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. it's an error if the cursor is already at the end of the edit buffer or on its last character. ๐ŸŒธ
  • vi-paste-next (vi command: p) โ€” inserts a copy of the cut buffer to the right of the cursor. it's an error if the cut buffer is empty. nothing to paste? nothing to paste. ๐Ÿคทโ€โ™€๏ธ
  • vi-paste-prev (vi command: P) โ€” inserts a copy of the cut buffer to the left of the cursor. it's an error if the cut buffer is empty. ๐Ÿ“
  • vi-prev-big-word (vi command: B) โ€” moves the cursor left, to the next beginning of a space delimited word. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. it's an error if the cursor is already at the beginning of the edit buffer. ๐Ÿ’ซ
  • vi-prev-char (vi command: F) โ€” reads one character from the terminal, bypassing the normal line editing functionality, then moves the cursor left to the next instance of that character in the edit buffer. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. if trying to read the character results in end of file or an error, it calls ed-end-of-file instead. it's an error if the character is not found searching to the left in the edit buffer. ๐Ÿ”
  • vi-prev-word (vi command: b) โ€” moves the cursor left, to the next beginning of a word. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. it's an error if the cursor is already at the beginning of the edit buffer. ๐ŸŒˆ
  • vi-redo (vi command: '.) โ€” redoes the last non-motion command. motion commands don't count, sorry, rules are rules โœจ
  • vi-repeat-next-char (vi command: ';) โ€” repeats the most recent character search in the same search direction. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. ๐ŸŽฏ
  • vi-repeat-prev-char (vi command: ',) โ€” repeats the most recent character search in the opposite search direction. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. ๐Ÿ”
  • vi-repeat-search-next (vi command: n) โ€” repeats the most recent history search in the same search direction. ๐Ÿงšโ€โ™€๏ธ
  • vi-repeat-search-prev (vi command: N) โ€” repeats the most recent history search in the opposite search direction. ๐Ÿ’œ
  • vi-replace-char (vi command: r) โ€” switches to vi replace mode, then automatically hops back to vi command mode after the next character typed. see ed-insert for a description of replace mode. it's an error if the cursor is at the end of the edit buffer. ๐Ÿซถ
  • vi-replace-mode (vi command: R) โ€” switches to vi replace mode. this is a variant of vi insert mode; see ed-insert for the difference. ๐Ÿ’…
  • vi-search-next (vi command: ?) โ€” replaces the edit buffer with the next matching history entry. ๐Ÿ‘‘
  • vi-search-prev (vi command: /) โ€” replaces the edit buffer with the previous matching history entry. ๐Ÿฆ‹
  • vi-substitute-char (vi command: s) โ€” deletes the character at the cursor and switches to vi insert mode. out with the old, in with the new ๐ŸŒธ
  • vi-substitute-line (vi command: S) โ€” deletes the entire contents of the edit buffer, saves a copy of it in the cut buffer, and enters vi insert mode. full reset, but make it reversible ๐Ÿ˜Œ
  • vi-to-column (vi command: |) โ€” moves the cursor to the column specified as the argument. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. straight to the column, no detours โญ
  • vi-to-history-line (vi command: G) โ€” replaces the edit buffer with the specified history entry. ๐ŸŽ€
  • vi-to-next-char (vi command: t) โ€” reads one character from the terminal, bypassing the normal line editing functionality, then moves the cursor right to the character before the next instance of that character in the edit buffer. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. if trying to read the character results in end of file or an error, it calls ed-end-of-file instead. it's an error if the character is not found searching to the right in the edit buffer. ๐Ÿ‘€
  • vi-to-prev-char (vi command: T) โ€” reads one character from the terminal, bypassing the normal line editing functionality, then moves the cursor left to the character after the next instance of that character in the edit buffer. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. if trying to read the character results in end of file or an error, it calls ed-end-of-file instead. it's an error if the character is not found searching to the left in the edit buffer. ๐Ÿ“
  • vi-undo (vi command: u) โ€” undoes the last change. the ctrl+z of the terminal, but cuter ๐Ÿ’ซ
  • vi-undo-line (vi command: U) โ€” undoes all changes to the edit buffer. full factory reset, no cap ๐Ÿ˜ญ
  • vi-yank (vi command: y) โ€” copies the string from the cursor to the position specified by the following movement command into the cut buffer. when given twice in a row, instead it copies the whole contents of the edit buffer into the cut buffer. ๐Ÿซถ
  • vi-yank-end (vi command: Y) โ€” copies the string from the cursor to the end of the edit buffer into the cut buffer. ๐Ÿ”ฅ
  • vi-zero (vi command: 0) โ€” if you're in argument input mode, it multiplies the argument by ten. otherwise, it moves the cursor to the beginning of the edit buffer. can be used as a movement command after vi_change_meta, vi_delete_meta, or vi_yank. dual purpose icon behaviour ๐Ÿ‘‘

๐ŸŽ€ Macros ๐ŸŽ€

okay so here's where it gets fun. if an input character is bound to the editor command ed-sequence-lead-in, editline tries to call a macro. if that input character by itself forms the name of a macro, bestie, that macro gets executed immediately. ๐Ÿ˜Œ

otherwise, additional input characters are read until either:

  • the string read forms the name of a macro โ€” in which case that macro is executed, or
  • the string read matches the beginning of none of the existing macro names โ€” in which case the string, including the final mismatching character, is discarded and the terminal bell is rung. ๐Ÿ’€ ouch.

There are two kinds of macros:

  • Command macros execute a single editor command.
  • Keyboard macros return a string of characters that is appended as a new line to the Input Queue.

The following command macros are defined by default in vi command mode and in emacs mode:

  • Esc [ A, Esc O A โ†’ ed-prev-history
  • Esc [ B, Esc O B โ†’ ed-next-history
  • Esc [ C, Esc O C โ†’ ed-next-char
  • Esc [ D, Esc O D โ†’ ed-prev-char
  • Esc [ F, Esc O F โ†’ ed-move-to-end
  • Esc [ H, Esc O H โ†’ ed-move-to-beg

In vi command mode, they are also defined by default without the initial escape character. ๐Ÿฆ‹

In addition, the editline library tries to bind the strings generated by the arrow keys as reported by the terminfo(5) database to these editor commands โ€” unless that would clobber user settings. ๐Ÿ™ˆ

โš ๏ธ real talk: that last bit is a "we'll try, but we won't stomp on your stuff" situation. your settings win, periodt.

So like, in emacs mode the two-character string Ctrl-X Ctrl-X is bound to the em-exchange-mark editor command. cute, iconic, a little mysterious ๐Ÿ’…

๐ŸŽ€ Input Queue ๐ŸŽ€

okay so the editline library keeps an input queue, and it runs in FIFO mode โ€” first in, first out, no cutting the line bestie โœจ Whenever it needs an input character, it takes the first character from the first line of the input queue. And when the queue is empty? It just reads from the terminal. simple as that ๐Ÿซถ

A line can be appended to the end of the input queue in several ways:

  • By calling one of the keyboard Macros ๐Ÿ“–
  • By calling the editor command vi-redo ๐Ÿ”
  • By calling the editor command vi-alias ๐Ÿท๏ธ
  • By pressing a key in emacs incremental search mode that doesn't have a special meaning in that mode but returns to normal emacs mode ๐Ÿ”
  • If an application program directly calls the functions el_push(3) or el_wpush(3), it can provide additional, program-specific ways of appending to the input queue โ€” main character energy fr fr ๐Ÿ‘‘

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

go read them, iykyk ๐Ÿ’–

โญ HISTORY โญ

This manual page first appeared in Ox 6.0 and Nx 8. vintage!! ๐Ÿฆ‹

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

-nosplit โ€” This manual page was written by Ingo Schwarze <schwarze@openbsd.org>. ty for your service ๐Ÿซก๐Ÿ’œ


and that's a wrap on the whole page bestie ๐ŸŽ€ this was EDITLINE(7), dated May 7, 2016 โ€” yes she's an elder but she still slays ๐Ÿ’…โœจ periodt.