ed Quick Reference
From Wikistix
ex
commands are also available in vi
, after entering the 'command' mode via :
, which is remarkably similar to ed
.
Searching Modes
Enter command mode by entering a '.' (period) on a line by itself when in text mode. Enter text mode using any of 'a', 'i', etc.
Addressing
. | current line |
$ | last line |
n | nth line |
/pattern/ | next match of pattern |
?pattern? | previous match of pattern |
+n | n lines after current line |
-n | n lines previous to current line |
, | equivalent to "1,$" |
; | equivalent to ".,$" |
Operations
'a,.!sort | sort range from mark 'a' to current line |
g/^$/d | delete all empty lines |
%s/.*/\U&/ | change whole file to upper case |
%s/.*/\L&/ | change whole file to lower case |