- Remove all real blank lines:
:g/^$/dor:v/./d - Remove all lines with only whitespace:
:g/^\s*$/d(delete lines with regex match) - Replacing multiple blank lines with one:
:v/./.,/./-1j - Replace multiple blank lines with one and delete single blank lines:
:g/\n\n/jand then:v/./.,/./-1j - Double space the file:
:g/^/pu =\"\n\"or:g/^/pu _
Other tricks:
- Reverse line order:
:g/^/m0 - Reverse two character:
xp - Reverse two lines:
ddp
Notes:
:[range]:gsearch for something and executeexcommands:vnegate the search pattern- Basic movements:
m,ncotmeans to copy lines m through n after line tm,nt$means to copy lines m through n to end of file-t$means to copy previous line to end of filem0means to move current line to the top.,+sm$-tmeans to move current line through (current+s) line to t-th last line of file