EDITLINE(7edit)
π editline(7edit) π
okay bestie, welcome to the editline(7edit) manual, part 1! This is literally the line editing user interface. We're gonna go through it together, no cap. β¨
NAME πΈ
editline β line editing user interface
DESCRIPTION π¦
When a program using the editline(3) library prompts for an input string using the function el_wgets(3), it reads characters from the terminal. Invalid input bytes that do not form characters are silently discarded. For each character read, one editor command is executed. The mapping of input characters to editor commands depends on the editing mode. There are three editing modes: vi insert mode, vi command mode, and emacs mode. The default is vi insert mode. The program can switch the default to emacs mode by using the el_set(3) or el_parse(3) functions, and the user can switch to emacs mode either in the editrc(5edit) configuration file or interactively with the ed-command editor command, in all three cases executing the bind -e builtin command.
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. π
Input character bindings β¨
All default bindings described below can be overridden by individual programs and can be changed with the editrc(5edit) bind builtin command.
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, 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.
vi insert mode π
In vi input mode, input characters are bound to the following editor commands by default:
Ctrl-D,EOFβvi-list-or-eofCtrl-H,BSβvi-delete-prev-charCtrl-J,LFβed-newlineCtrl-M,CRβed-newlineCtrl-Qβed-tty-start-outputCtrl-Sβed-tty-stop-outputCtrl-Uβvi-kill-line-prevCtrl-Vβed-quoted-insertCtrl-Wβed-delete-prev-wordCtrl-[,ESCβvi-command-modeCtrl-\,QUITβed-tty-sigquitCtrl-?,DELβvi-delete-prev-char
All other input characters except the NUL character (Ctrl-@) are bound to ed-insert.
vi command mode π
In vi command mode, input characters are bound to the following editor commands by default:
Ctrl-Aβed-move-to-begCtrl-C,INTβed-tty-sigintCtrl-Eβed-move-to-endCtrl-H,BSβed-delete-prev-charCtrl-J,LFβed-newlineCtrl-Kβed-kill-lineCtrl-L,FFβed-clear-screenCtrl-M,CRβed-newlineCtrl-Nβed-next-historyCtrl-Oβed-tty-flush-outputCtrl-Pβed-prev-historyCtrl-Qβed-tty-start-outputCtrl-Rβed-redisplayCtrl-Sβed-tty-stop-outputCtrl-Uβvi-kill-line-prevCtrl-Wβed-delete-prev-wordCtrl-[,ESCβem-meta-nextCtrl-\,QUITβed-tty-sigquitSpaceβ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-prev0βvi-zero1to9βed-argument-digit:βed-command;βvi-repeat-next-char?βvi-search-next@βvi-aliasAβvi-add-at-eolBβvi-prev-big-wordCβvi-change-to-eolDβed-kill-lineEβvi-end-big-wordFβvi-prev-charGβvi-to-history-lineIβvi-insert-at-bolJβed-search-next-historyKβed-search-prev-historyNβvi-repeat-search-prevOβed-sequence-lead-inPβvi-paste-prevRβvi-replace-modeSβvi-substitute-lineTβvi-to-prev-charUβvi-undo-lineWβvi-next-big-wordXβed-delete-prev-charYβvi-yank-end[βed-sequence-lead-in^βed-move-to-beg_βvi-history-wordaβvi-addbβvi-prev-wordcβvi-change-metadβvi-delete-metaeβvi-end-wordfβvi-next-charhβed-prev-chariβvi-insertjβed-next-historykβed-prev-historylβed-next-charnβvi-repeat-search-nextpβvi-paste-nextrβvi-replace-charsβvi-substitute-chartβvi-to-next-charuβvi-undovβvi-histeditwβvi-next-wordxβed-delete-next-charyβvi-yank|βvi-to-column~βvi-change-caseCtrl-?,DELβed-delete-prev-charMeta-Oβed-sequence-lead-inMeta-[βed-sequence-lead-in
emacs mode π
In emacs mode, input characters are bound to the following editor commands by default:
0to9βed-digitCtrl-@,NULβem-set-markCtrl-Aβed-move-to-begCtrl-Bβed-prev-charCtrl-C,INTβed-tty-sigintCtrl-D,EOFβem-delete-or-listCtrl-Eβed-move-to-endCtrl-Fβed-next-charCtrl-H,BSβem-delete-prev-charCtrl-J,LFβed-newlineCtrl-Kβed-kill-lineCtrl-L,FFβed-clear-screenCtrl-M,CRβed-newlineCtrl-Nβed-next-historyCtrl-Oβed-tty-flush-outputCtrl-Pβed-prev-historyCtrl-Qβed-tty-start-outputCtrl-Rβed-redisplayCtrl-Sβed-tty-stop-outputCtrl-Tβed-transpose-charsCtrl-Uβed-kill-lineCtrl-Vβed-quoted-insertCtrl-Wβem-kill-regionCtrl-Xβed-sequence-lead-inCtrl-Yβem-yankCtrl-Z,TSTPβed-tty-sigtstpCtrl-[,ESCβem-meta-nextCtrl-\,QUITβed-tty-sigquitCtrl-]βed-tty-dsuspCtrl-?,DELβem-delete-prev-charCtrl-Meta-Hβed-delete-prev-wordCtrl-Meta-Lβed-clear-screenCtrl-Meta-_βem-copy-prev-wordMeta-0to9βed-argument-digitMeta-Bβed-prev-wordMeta-Cβem-capitol-caseMeta-Dβem-delete-next-wordMeta-Fβem-next-wordMeta-Lβem-lower-caseMeta-Nβed-search-next-historyMeta-Oβed-sequence-lead-inMeta-Pβed-search-prev-historyMeta-Uβem-upper-caseMeta-Wβem-copy-regionMeta-Xβed-commandMeta-[βed-sequence-lead-inMeta-bβed-prev-wordMeta-cβem-capitol-caseMeta-dβem-delete-next-wordMeta-fβem-next-wordMeta-lβem-lower-caseMeta-nβed-search-next-historyMeta-pβed-search-prev-historyMeta-uβem-upper-caseMeta-wβem-copy-regionMeta-xβed-commandCtrl-Meta-?βed-delete-prev-word
The remaining ascii(7) characters in the range 0x20 to 0x7e are bound to ed-insert.
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.
Editor commands π
Most editor commands accept an optional argument. The argument is entered by prefixing the editor command with one or more of the editor commands ed-argument-digit, ed-digit, em-universal-argument, or 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.
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.
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.
In the following list, the default key bindings are listed after each editor command.
ed-argument-digit(vi command:1to9; emacs:Meta-0toMeta-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.ed-clear-screen(vi command: Ctrl-L;emacs: Ctrl-L, Ctrl-Meta-L) β Clears the whole screen and shows your edit buffer at the top. Any argument? Ignored, bestie. πed-command(vi command: β:β;emacs: Meta-X, Meta-x) β Reads a line from the terminal, totally bypassing the normal line editing, and runs that line as aneditrc(5edit)builtin command. If you're in vi command mode, it also switches you back to vi insert mode. Any argument? Ignored. πed-delete-next-char(vi command: x) β Deletes the character under the cursor. Give it an argument and it deletes that many characters. In emacs mode, it's an error if the cursor is at the end of the edit buffer. In vi mode, if you're at the end, it deletes the last character in the edit buffer, and it's an error if the buffer is empty. πed-delete-prev-char(vi command: X, Ctrl-H, BS, Ctrl-?, DEL) β Deletes the character to the left of the cursor. With an argument, deletes that many characters. It's 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-?) β Moves left to the closest beginning of a word, deletes everything from there to the cursor, and saves it to the cut buffer. With an argument, deletes that many words. It's an error if the cursor is at the beginning of the edit buffer. π¦ed-digit(emacs: 0 to 9) β If you're in argument input mode, it appends the digit you typed to the argument being read. Otherwise, it callsed-insert. It's an error if the input character isn't a digit or if the existing argument is already greater than a million. π₯ed-end-of-file(not bound by default) β Discards the edit buffer and tells the program it's end of file. Any argument? Ignored. πed-ignore(various) β Throws away the input character and does absolutely nothing. The void. πed-insert(vi input: almost all;emacs: printable characters) β In insert mode, inserts the input character to the left of the cursor. In replace mode, it overwrites the character at the cursor and moves the cursor right by one. Accepts an argument to do this repeatedly. It's an error if the input character is the NUL character (Ctrl-@). Also, if it fails to enlarge the edit buffer, that's an error too. π«Άed-kill-line(vi command: D, Ctrl-K;emacs: Ctrl-K, Ctrl-U) β Deletes from the cursor to the end of the line and saves it to the cut buffer. Any argument? Ignored. β¨ed-move-to-beg(vi command: ^, Ctrl-A;emacs: Ctrl-A) β In vi mode, moves the cursor to the first non-space character in the edit buffer. In emacs mode, moves it to the very beginning of the edit buffer. Any argument? Ignored. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. πed-move-to-end(vi command: $, Ctrl-E;emacs: Ctrl-E) β Moves the cursor to the end of the edit buffer. Any argument? Ignored. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. πΈed-newline(all modes: Ctrl-J, LF, Ctrl-M, CR) β Appends a newline character to the edit buffer and returns the edit buffer to the program. Any argument? Ignored. πed-next-char(vi command: Space, l;emacs: Ctrl-F) β Moves the cursor one character position to the right. With an argument, moves by that many characters. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It's 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) β Replaces the edit buffer with the next history line. That line is older than the current one. With an argument, goes forward by that many history lines. It's a non-fatal error to advance by more lines than are available. πed-next-line(not bound by default) β Moves the cursor down one line. With an argument, moves down by that many lines. It's an error if the edit buffer doesn't have enough newline characters to the right of the cursor position. πed-prev-char(vi command: h;emacs: Ctrl-B) β Moves the cursor one character position to the left. With an argument, moves by that many characters. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It's 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) β Replaces the edit buffer with the previous history line. That line is newer than the current one. With an argument, goes back by that many lines. It's a non-fatal error to back up by more lines than are available. β¨ed-prev-line(not bound by default) β Moves the cursor up one line. With an argument, moves up by that many lines. It's an error if the edit buffer doesn't have enough newline characters to the left of the cursor position. πed-prev-word(emacs: Meta-B, Meta-b) β Moves the cursor left to the closest beginning of a word. With an argument, repeats that many times. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It's an error if the cursor is already at the beginning of the edit buffer. πed-quoted-insert(vi insert, emacs: Ctrl-V) β Reads one character from the terminal, bypassing normal line editing, and callsed-inserton it. If trying to read the character returns end of file or an error, it callsed-end-of-fileinstead. π₯ed-redisplay(vi command, emacs: Ctrl-R) β Redisplays everything. Any argument? Ignored. πed-search-next-history(vi command: J;emacs: Meta-N, Meta-n) β Replaces the edit buffer with the next matching history entry. π¦ed-search-prev-history(vi command: K;emacs: Meta-P, Meta-p) β Replaces the edit buffer with the previous matching history entry. πΈed-sequence-lead-in(vi cmd: O, [;emacs: Ctrl-X;both: Meta-O, Meta-[) β Calls a macro. Check out the section about βMacrosβ below for the tea. πed-start-over(not bound by default) β Discards the contents of the edit buffer and starts from scratch. Any argument? Ignored. β¨ed-transpose-chars(emacs: Ctrl-T) β Swaps the character at the cursor with the one to its left, then moves the cursor to the character to the right of the two exchanged characters. Any argument? Ignored. It's an error if the cursor is at the beginning of the edit buffer or if the edit buffer has less than two characters. πed-unassigned(all characters not listed) β This editor command always results in an error. πem-capitol-case(emacs: Meta-C, Meta-c) β Capitalizes the string from the cursor to the end of the current word. That means: if it has at least one alphabetic character, it converts the first alphabetic character to upper case, and all characters to the right of it to lower case. Either way, it moves the cursor to the next character after the end of the current word. πem-copy-prev-word(emacs: Ctrl-Meta-_) β Copies the string from the beginning of the current word to the cursor and inserts it to the left of the cursor. Moves the cursor to the character after the inserted string. It's an error if the cursor is at the beginning of the edit buffer. πem-copy-region(emacs: Meta-W, Meta-w) β Copies the string from the cursor to the mark into the cut buffer. It's an error if the mark isn't set. πem-delete-next-word(emacs: Meta-D, Meta-d) β Deletes the string from the cursor to the end of the current word and saves it to the cut buffer. It's an error if the cursor is at the end of the edit buffer. π₯em-delete-or-list(emacs: Ctrl-D, EOF) β If the cursor isn't at the end of the line, deletes the character at the cursor. If the edit buffer is empty, it indicates end of file to the program. It's an error if the cursor is at the end of the edit buffer and the edit buffer isn't empty. πem-delete-prev-char(emacs: Ctrl-H, BS, Ctrl-?, DEL) β Deletes the character to the left of the cursor. It's an error if the cursor is at the beginning of the edit buffer. π¦em-exchange-mark(not bound by default) β Exchanges the cursor and the mark. πem-gosmacs-transpose(not bound by default) β Exchanges the two characters to the left of the cursor. It's 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) β Deletes the entire contents of the edit buffer and saves it to the cut buffer. πem-kill-region(emacs: Ctrl-W) β Deletes the string from the cursor to the mark and saves it to the cut buffer. It's an error if the mark isn't set. πem-lower-case(emacs: Meta-L, Meta-l) β Converts the characters from the cursor to the end of the current word to lower case. πem-meta-next(vi command, emacs: Ctrl-[, ESC) β Sets bit0x80on 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 get the same effect. π₯em-next-word(Meta-F, Meta-f) β Moves the cursor to the end of the current word. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It's an error if the cursor is already at the end of the edit buffer. π¦em-set-mark(emacs: Ctrl-Q, NUL) β Sets the mark at the current cursor position. πem-toggle-overwrite(insert) β Switches from insert mode to overwrite mode or vice versa. πem-universal-argument(not bound by default) β If in argument input mode, multiplies the argument by 4. Otherwise, switches to argument input mode and sets the argument to 4. It's an error if the existing argument is already greater than a million. β¨em-upper-case(emacs: Meta-U, Meta-u) β Converts the characters from the cursor to the end of the current word to upper case. πem-yank(emacs: Ctrl-Y) β Pastes the cut buffer to the left of the cursor. πΈvi-add(vi command: a) β Switches to vi insert mode. Unless the cursor is already at the end of the edit buffer, it moves 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. Append at the end, periodt. πvi-alias(vi command:@) β If an alias function was defined by calling theel_set(3)orel_wset(3)function with the argumentEL_ALIAS_TEXT, read one character from the terminal bypassing the normal line editing functionality, call the alias function passing the argument that was specified withEL_ALIAS_TEXTas the first argument and the character read, with an underscore prepended, as the second argument, and pass the string returned from the alias function toel_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. This one is lowkey advanced, bestie β iykyk. π¦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. Tilde got that flip energy. β¨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. So iconic. π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. Boom, line cleanup. π§vi-command-mode(vi insert: Ctrl-[, ESC) β Discard pending actions and arguments and switch to vi command mode. Unless the cursor is already at the beginning of the edit buffer, move it to the left by one character position. Escape from insert mode, iconic. π₯vi-comment-out(vi command:#) β Insert a#character at the beginning of the edit buffer and return the edit buffer to the program. Comment out and yeet it back. πvi-delete-meta(vi command:d) β 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. The delete queen. πvi-delete-prev-char(vi insert: Ctrl-H, BS, Ctrl-?, DEL) β Delete the character to the left of the cursor. It is an error if the cursor is already at the beginning of the edit buffer. Backspace bestie. πvi-end-big-word(vi command:E) β Move the cursor to the end of the current space delimited word. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It is an error if the cursor is already at the end of the edit buffer. Big word energy. πvi-end-word(vi command:e) β Move the cursor to the end of the current word. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It is an error if the cursor is already at the end of the edit buffer. Smol word, same vibe. πvi-history-word(vi command:_) β Insert the first word from the most recent history entry after the cursor, move the cursor after to the character after the inserted word, and switch to vi insert mode. It is an error if there is no history entry or the most recent history entry is empty. History word? Obsessed. πvi-histedit(vi command:v) β Edit the buffer with the editor and return the edit buffer to the program. The editor specified by theEDITORenvironment variable will be invoked instead of the default editorvi(1). Main character editor moment. πvi-insert(vi command:i) β Enter insert mode. Simple. Iconic. Periodt. πvi-insert-at-bol(vi command:I) β Move the cursor to the beginning of the edit buffer and switch to vi insert mode. Bol = beginning of line, bestie. π¦vi-kill-line-prev(vi: Ctrl-U) β Delete the string from the beginning of the edit buffer to the cursor and save it to the cut buffer. Kill line, but make it prev. πvi-list-or-eof(vi insert: Ctrl-D,EOF) β If the edit buffer is empty, indicate end of file to the program. It is an error if the edit buffer is not empty. EOF vibes. πΈvi-match(vi command:%) β Consider opening and closing parentheses, braces, and brackets as delimiters. If the cursor is not at a delimiter, move it to the right until it gets to one, then move it to the matching delimiter. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It is an error if there is 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. Matchy matchy. β¨vi-next-big-word(vi command:W) β Move the cursor to the right to the beginning of the next space delimited word. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It is an error if the cursor is already at the end of the edit buffer or on its last character. Next big word, go off. π₯vi-next-char(vi command:f) β Read one character from the terminal bypassing the normal line editing functionality and move the cursor to the right to the next instance of that character in the edit buffer. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. If trying to read the character results in end of file or an error, called-end-of-fileinstead. It is an error if the character is not found searching to the right in the edit buffer. Find char, slay. πvi-next-word(vi command:w) β Move the cursor to the right to the beginning of the next word. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It is an error if the cursor is already at the end of the edit buffer or on its last character. Word hop. πvi-paste-next(vi command:p) β Insert a copy of the cut buffer to the right of the cursor. It is an error if the cut buffer is empty. Paste next, periodt. πvi-paste-prev(vi command:P) β Insert a copy of the cut buffer to the left of the cursor. It is an error if the cut buffer is empty. Paste prev, same but left. π¦vi-prev-big-word(vi command:B) β Move the cursor to the left to the next beginning of a space delimited word. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It is an error if the cursor is already at the beginning of the edit buffer. Back it up, big word style. πvi-prev-char(vi command:F) β Read one character from the terminal bypassing the normal line editing functionality and move the cursor to the left to the next instance of that character in the edit buffer. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. If trying to read the character results in end of file or an error, called-end-of-fileinstead. It is an error if the character is not found searching to the left in the edit buffer. Find backwards, iconic. β¨vi-prev-word(vi command:b) β Move the cursor to the left to the next beginning of a word. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. It is an error if the cursor is already at the beginning of the edit buffer. Word hop but backwards. πvi-redo(vi command:.) β Redo the last non-motion command. Do it again, bestie. πvi-repeat-next-char(vi command:;) β Repeat the most recent character search in the same search direction. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. Same direction, same vibes. π«vi-repeat-prev-char(vi command:,) β Repeat the most recent character search in the opposite search direction. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. Opposite direction, plot twist. πvi-repeat-search-next(vi command:n) β Repeat the most recent history search in the same search direction. History search again, no cap. πvi-repeat-search-prev(vi command:N) β Repeat the most recent history search in the opposite search direction. History search but backwards. πvi-replace-char(vi command:r) β Switch to vi replace mode, and automatically switch back to vi command mode after the next character typed. Seeed-insertfor a description of replace mode. It is an error if the cursor is at the end of the edit buffer. One-char replace, so cute. πvi-replace-mode(vi command:R) β Switch to vi replace mode. This is a variant of vi insert mode; seeed-insertfor the difference. Replace mode activated. πvi-search-next(vi command:?) β Replace the edit buffer with the next matching history entry. Search next, slay. πvi-search-prev(vi command:/) β Replace the edit buffer with the previous matching history entry. Search prev, same energy. πvi-substitute-char(vi command:s) β Delete the character at the cursor and switch to vi insert mode. Substitute char, boom. π₯vi-substitute-line(vi command:S) β Delete the entire contents of the edit buffer, save a copy of it in the cut buffer, and enter vi insert mode. Whole line substitute, iconic. πvi-to-column(vi command:|) β Move the cursor to the column specified as the argument. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. To column, precise. πvi-to-history-line(vi command:G) β Replace the edit buffer with the specified history entry. Go to history line, periodt. πvi-to-next-char(vi command:t) β Read one character from the terminal bypassing the normal line editing functionality and move the cursor to the right to the character before the next instance of that character in the edit buffer. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. If trying to read the character results in end of file or an error, called-end-of-fileinstead. It is an error if the character is not found searching to the right in the edit buffer. To next char, not on it, before it. π«vi-to-prev-char(vi command:T) β Read one character from the terminal bypassing the normal line editing functionality and move the cursor to the left to the character after the next instance of that character in the edit buffer. Can be used as a movement command aftervi_change_meta,vi_delete_meta, orvi_yank. If trying to read the character results in end of file or an error, called-end-of-fileinstead. It is an error if the character is not found searching to the left in the edit buffer. To prev char, backwards but after it. πvi-undo(vi command:u) β Undo the last change. Undo, bestie. β©οΈvi-undo-line(vi command:U) β Undo all changes to the edit buffer. Undo everything, no cap. β©οΈvi-yank(vi command:y) β Copy the string from the cursor to the position specified by the following movement command to the cut buffer. When given twice in a row, instead copy the whole contents of the edit buffer to the cut buffer. Yank = copy, periodt. πvi-yank-end(vi command:Y) β Copy the string from the cursor to the end of the edit buffer to the cut buffer. Yank to end, slay. β¨
πΈ vi-zero (vi command: 0) πΈ
- If you're in argument input mode, it multiplies the argument by ten. Ten!! That's the whole job π
- Otherwise, it moves the cursor to the beginning of the edit buffer, which is giving "rewind me to the start bestie" energy π
- You can also use it as a movement command after
vi_change_meta,vi_delete_meta, orvi_yank. Versatile queen π
π§ Macros π§
So here's the tea: 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, then that macro just runs. Periodt.
Otherwise, it keeps reading more input characters until either:
- the string it's 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 gets rung π
Not the bell. Anything but the bell. π
There are two kinds of macros, and yes they have different vibes:
- Command macros β execute a single editor command.
- Keyboard macros β return a string of characters that gets appended as a new line to the βInput Queueβ.
β¨ The default command macros β¨
These are defined by default in vi command mode and in emacs mode:
Esc [ A,Esc O Aβed-prev-historyEsc [ B,Esc O Bβed-next-historyEsc [ C,Esc O Cβed-next-charEsc [ D,Esc O Dβed-prev-charEsc [ F,Esc O Fβed-move-to-endEsc [ H,Esc O Hβed-move-to-beg
In vi command mode, these are also defined by default without the initial escape character. Iconic behaviour honestly π«Ά
On top of that, 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, because respecting people's config is the bare minimum, no cap.
And in emacs mode, the two-character string βCtrl-X Ctrl-Xβ is bound to the em-exchange-mark editor command. Cute.
π Input Queue π
The editline library keeps an input queue, and it runs in FIFO mode. Whenever it needs an input character, it takes the first character from the first line of the input queue. When the queue is empty, it reads from the terminal instead. 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)orel_wpush(3), it can provide additional, program-specific ways of appending to the input queue. Main character energy from the app, honestly β¨
π SEE ALSO π
π°οΈ HISTORY π°οΈ
This manual page first appeared in OpenBSD 6.0 and NetBSD 8. A true elder of the game π
π AUTHORS π
This manual page was written by Ingo Schwarze <schwarze@openbsd.org>. Thank you for your service, king π«‘
Okay bestie that's the whole page, we made it to the end π This one's from the Debian crew, dated January 31, 2026, and it lives at EDITLINE(7edit). Go forth and press your arrow keys, you gorgeous little terminal wizard π¦β¨
π¦ where this page comes from
- ubuntu stonking: libedit2 3.1-20260512-1
- Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms