| wiki | english |
| gnu | manual |
- 1973
- by Ken Thompson (30)
- Line oriented editor, as opossed to character oriented editor
- 55k on x86_64
- part of the POSIX standard, mandatory
- info ed
- shitposting https://x.com/ed1conf
- online game? http://edbrowse.org/
Why?
- being part of POSIX, is everywhere
- to work on embedded device with few cli binaries
- to work with small screens
cli
rlwrap ed -p '> '
ed [OPTIONS] [FILE]
red [OPTIONS] [FILE]
| -E | –extended-regexp | - | |
| -s | –quiet –silent | - | turn OFF byte counts |
| -p | –prompt | STRING | |
| -v | –verbose | - | prints error msgs |
| -r | –restricted | - | disable edit outside CWD |
| disable (!) command |
commands
[ADDRESS[,ADDRESS]]COMMAND[PARAMETERS]
| . | exit insert mode | ||
| .,. | p | - | prints |
| .,. | n | - | prints w/number |
| .,. | l | - | prints verbose |
| u | undo last edit | ||
| .+1 | \n | - | new line |
address
| = | prints nr of buffer lines |
| .= | prints nr current line |
| . | prints current line |
| N | jumps to N line number |
| $ | jumps to last line |
| % | entire file (aka 1,$) |
| +1 | moves cursor down |
| -1 | moves cursor up |
address range
| , | whole file |
| % | whole file |
| 1,$ | whole file |
| foo,/bar/ | lines between next foo and bar |
| ?foo?,/bar/ | lines between previous foo and bar |
search
| // | repeat last search forward | ||
| ?? | repeat last search backward | ||
| 1,$ | /re | search | |
| 1,$ | g/re | global search | |
| 1,$ | g/re/p | global search, explicit print | |
| 1,$ | G/re | global search, interactive action | |
| 1,$ | v/re | global inverse search | |
| 1,$ | V/re | global inverse search interactive action |
substitution (.,.)
| s | repeats lasts substitution |
| s/re | substitutes 1st re(gex) with nothing |
| s/re/bar | substitutes 1st re(gex) on current line |
| s/re/bar/I | substitutes 1st re(gex) on current line, case insensitive |
| s/re/bar/2 | substitutes 2nd re(gex) on current line |
| s/re/bar/g | substitutes ALL re(gex) on current line |
| s/re/%/ | substitutes 1st re(gex) with prev subst |
| s/re/*&*/ | substitutes 1st re(gex) with re |
edit
| . | a | - | append mode |
| . | i | - | insert mode |
| .,. | c | - | change |
| j | joins lines | ||
| .,. | d | - | delete |
| .,. | t | . | transfers/copies and paste lines |
| .,. | m | . | moves/cuts and paste lines |
| .,. | y | - | yank/copies to cut buffer |
| . | x | - | pastes the cut buffer |
file / command
| f | shows current file name | ||
| f FILE | sets output FILE name | ||
| e FILE | edit file, reads it and sets curr file | ||
| 1,$ | w FILE | - | write to a file |
| 1,$ | w !cmd | - | write to command |
| 1,$ | W FILE | - | appends to file |
| $ | r FILE | read from file | |
| $ | r !cmd | read from command | |
| ! CMD | executes command, "%" is curr filename | ||
| !! | executes last command |
misc
| Q | quits unconditionally |
| q | quits |
| P | enables prompt |
| H | enables error reporting |
| h | prints last error msg |
snippets
| s | repeat previous substitution |
| g/Needle/p | shows lines matching |
| 3,10c | replaces range with given text |
| r !xsel | paste from clipboard |
| ;p | prints lines from curr to EOF |
| ,p | prints all lines |
| ,n | prints all lines with numbers |
| foo;/bar/-1p | prints between "foo" and "bar" |
| w !diff -u - % | diff buffer with file |
| 2w !wc | count words, and chars on line 2 |
| w !wc | count buffer lines, chars |
| !wc % | " |
ex
- wiki https://en.wikipedia.org/wiki/Ex_(text_editor)
- 1978
- by Bill Joy (24)
- part of the POSIX standard, optional