LEDIT(1)

πŸ“¦
version 2.04 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’… NAME πŸ’…

okay bestie, gather round, this is the manual page for ledit(1) β€” the command is ledit, and it's a line editor, currently at version 2.04. lowercase name, big personality, we love her.


✨ SYNOPSIS ✨

ledit [-h file] [-x] [-t] [-l length] [-a | -u] [command options]

πŸ¦‹ DESCRIPTION πŸ¦‹

so the way ledit works is: you're running some interactive command, and ledit lets you edit the lines one by one as you go. while you're typing a line, certain keys β€” the control ones and the meta ones β€” actually mean something. like, you can insert characters in the middle of the line (yes, mid-line, no more rage-deleting), jump to the beginning or the end of the line, pull up a previous line, search for a line matching a pattern, etc. it's giving actual editor but make it terminal. πŸ’–


πŸŽ€ OPTIONS πŸŽ€

here's the full menu, no skipping:

  • -h file β€” saves the lines you type (aka the history) into file. the default is that they just vibe in memory only, which means they're gone the second the program ends 😭.
  • -x β€” extends the history file (the one you gave to -h) if it already exists. the default behaviour is to truncate that history file instead.
  • -t β€” displays the sequences that the keys generate. this one's for debugging, iykyk.
  • -v β€” prints the ledit version and dips out. ✌️
  • -l length β€” tells it that length is the maximum line length that gets displayed. if the line you're editing is longer than that, the line scrolls horizontally while you edit. default is 70.
  • -a β€” ascii encoding: any character whose code is greater than 128 gets displayed as a backslash followed by its code.
  • -u β€” unicode encoding: your terminal must have been set in unicode mode first. see the commands unicode_start and unicode_stop. 🌈
  • command options β€” runs the command command along with its possible options. this has to be the last option of ledit. the default value is "cat".

⌨️ KEYS BINDINGS ⌨️

when ledit starts up, a bunch of default key bindings are already defined. you can complete them with a "leditrc" file β€” that whole situation is in the LEDITRC section below. πŸ‘‡

just so we're speaking the same language: the caret sign ^ means "control", and the sequence M- means "meta" (either via the "meta" prefix, or by pressing the "escape" key beforehand). examples, because bestie deserves clarity:

  • ^a β€” press the "control" key, then press "a", then release "a", then release "control".
  • M-a β€” press the "meta" key, then press "a", then release "a", then release "meta". OR: press and release the "escape" key, then press and release "a". heads up though β€” the "meta" manipulation may not work on some systems, and in that case you just use the "escape" manipulation instead. πŸ’€

the default editing commands are:

  • ^a β€” beginning of line
  • ^e β€” end of line
  • ^f β€” forward char
  • ^b β€” backward char
  • M-f β€” forward word
  • M-b β€” backward word
  • TAB β€” complete file name
  • ^p β€” previous line in history
  • ^n β€” next line in history
  • M-< β€” first line in history
  • M-> β€” last line in history
  • ^r β€” reverse search in history (see below)
  • ^d β€” delete char (or EOF if the line is empty)
  • ^h β€” (or backspace) backward delete char
  • ^t β€” transpose chars
  • M-c β€” capitalize word
  • M-u β€” upcase word
  • M-l β€” downcase word
  • M-d β€” kill word
  • M-^h β€” (or M-del or M-backspace) backward kill word
  • ^q β€” insert next char
  • M-/ β€” expand abbreviation
  • ^k β€” cut until end of line
  • ^y β€” paste
  • ^u β€” line discard
  • ^l β€” redraw current line
  • ^g β€” abort prefix
  • ^c β€” interrupt
  • ^z β€” suspend
  • ^\ β€” quit
  • return β€” send line
  • ^x β€” send line and show next history line
  • other β€” insert char

🌸 Arrow Keys 🌸

the arrow keys work too β€” as long as your keyboard returns standard key sequences:

  • up arrow β€” previous line in history
  • down arrow β€” next line in history
  • right arrow β€” forward char
  • left arrow β€” backward char

🧚 Other Keys 🧚

  • home β€” beginning of line
  • end β€” end of line
  • delete β€” delete char
  • page up β€” previous line in history
  • page down β€” next line in history
  • shift home β€” beginning of history
  • shift end β€” end of history

the reverse search is incremental, meaning ledit searches backwards through the history for a line holding the characters you've typed. type "a" and it finds the first line before the current one that holds an "a" and shows it to you. then type a "b" and it searches for a line holding "ab", and so on, building the pattern as you go. ✨

if you type ^h (or backspace), it goes back to the previous line it found. to cancel the whole search, type ^g. to find another line before the current one holding the same string, type ^r. and to stop editing and display the current line it found, type "escape" β€” though ngl, other commands of the normal editing also stop the editing, as long as they're not ^h, ^g, or ^r.

summary of reverse search commands:

  • ^g β€” abort search
  • ^r β€” search previous same pattern
  • ^h β€” (or backspace) search without the last char
  • del β€” search without the last char
  • any other command β€” stop search and show the line found

πŸ“œ LEDITRC πŸ“œ

if the environment variable LEDITRC is set, it holds the name of the leditrc file. otherwise, it's the file named ".leditrc" sitting in your home directory. 🏠

when it starts, ledit reads that file (if it exists, obviously) to modify or complete the default bindings. and here's the cute part: if that file gets changed while you're reading lines, it gets read again so the new file is taken into account. it's keeping up with you fr fr. πŸ’…

binding lines are the ones that start with a string defining the key sequence, followed by a colon and then a binding. a binding is either a string or a command. every other line? ignored, no thoughts, head empty. for example, this line:

"\C-a": beginning-of-line

binds the sequence "control-a" to the command "beginning-of-line".

the key sequence may contain these specific meta-sequences:

\C-   followed by a key: "control" of this key
\M-   followed by a key: "meta" of this key
\e    the "escape" key
\nnn  where nnn is one, two, or three octal digits, or:
\xnn  where nn is one or two hexadecimal digits:
        the binary representation of a byte
\a    bell = \C-g
\b    backspace = \C-h
\d    delete = \277
\f    form feed = \C-l
\n    newline = \C-j
\r    carriage return = \C-m
\t    tabulation = \C-i
\v    vertical tabulation = \C-k

and here come the commands, the whole squad, all of them:

  • abort: do nothing
  • accept-line: send the current line
  • backward-char: move the cursor to the previous character
  • backward-delete-char: delete the previous character
  • backward-kill-word: delete the previous word
  • backward-word: move the cursor before the previous word
  • beginning-of-history: display the first line of the history
  • beginning-of-line: move the cursor at the beginning of the line
  • capitalize-word: uppercase the first char and lowercase the rest
  • delete-char: delete the character under the cursor
  • delete-char-or-end-of-file: same but eof if no character in the line
  • downcase-word: lowercase whole word
  • end-of-history: display the last line of the history
  • end-of-line: move the cursor to the end of the line
  • expand-abbrev: try to complete the word by looking at the history
  • expand-to-file-name: try to complete the word from a file name
  • forward-char: move the cursor after the next word
  • forward-word: move the cursor to the next character
  • interrupt: interrupt command (send control-C)
  • kill-line: delete from the cursor to the end and save in buffer
  • kill-word: delete the next word
  • next-history: display the next line of the history
  • operate-and-get-next: send line and display the next history line
  • previous-history: display the previous line of the history
  • quit: quit ledit
  • quoted-insert: insert the next character as it is
  • redraw-current-line: redisplay the current line
  • reverse-search-history: backward search in the history
  • suspend: suspend ledit (send control-Z)
  • transpose-chars: exchange the last two characters
  • unix-line-discard: kill current line
  • upcase-word: uppercase whole word
  • yank: insert kill buffer

πŸ’€ KNOWN BUGS πŸ’€

okay bestie, this is the scary part, pay attention:

  • if ledit has been launched inside a shell script, the suspend command kills it and its command. the fix: use exec ledit comm instead of ledit comm. 😭
  • the suspend command stops ledit but not the program it called. so do not do this if the called program is not waiting on standard input.
  • on some systems (e.g. alpha), pasting too many characters works badly and may block the terminal. probably a kernel problem. no solution. not me finding out the hard way πŸ™ˆ.

πŸ”— SEE ALSO πŸ”—

unicode_start(1), unicode_stop(1)


πŸ‘‘ AUTHOR πŸ‘‘

Daniel de Rauglaudre, at INRIA, France. daniel.de_rauglaudre@inria.fr


and that's the whole page, periodt. 🫢 this one came straight outta INRIA, dated Wed Jan 23, 2008 β€” vintage but still slaying. πŸ’–βœ¨