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-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. ๐
๐ง In vi command mode
Input characters are bound to these 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
๐ In emacs mode
Input characters are bound to these 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 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-digited-digitem-universal-argumentvi-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: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. (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 aneditrc(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:0to9) โ If in argument input mode, append the input digit to the argument being read. Otherwise, called-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 theNULcharacter (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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 called-inserton it. If trying to read the character returns end of file or an error, called-end-of-fileinstead. ๐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 bit0x80on the next character typed. Unless the resulting code point is printable, holding down theMeta-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 aftervi_change_meta,vi_delete_meta, orvi_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 by4. Otherwise, switch to argument input mode and set the argument to4. 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 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. ๐ช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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_yank. if trying to read the character results in end of file or an error, it callsed-end-of-fileinstead. 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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_yank. if trying to read the character results in end of file or an error, it callsed-end-of-fileinstead. 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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_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. seeed-insertfor 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; seeed-insertfor 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 aftervi_change_meta,vi_delete_meta, orvi_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 aftervi_change_meta,vi_delete_meta, orvi_yank. if trying to read the character results in end of file or an error, it callsed-end-of-fileinstead. 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 aftervi_change_meta,vi_delete_meta, orvi_yank. if trying to read the character results in end of file or an error, it callsed-end-of-fileinstead. 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 aftervi_change_meta,vi_delete_meta, orvi_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,EscOAโed-prev-historyEsc[B,EscOBโed-next-historyEsc[C,EscOCโed-next-charEsc[D,EscODโed-prev-charEsc[F,EscOFโed-move-to-endEsc[H,EscOHโ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)orel_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.
๐ฆ where this page comes from
- opensuse-leap 16.0: libedit-devel 20210910.3.1-160000.2.2 ยท BSD-3-Clause
- opensuse-leap 16.0: libedit-devel 20210910.3.1-160000.2.2 ยท BSD-3-Clause
- opensuse-leap 16.0: libedit-devel 20210910.3.1-160000.2.2 ยท BSD-3-Clause
- opensuse-leap 16.0: libedit-devel 20210910.3.1-160000.2.2 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms