Tricks
"==============================================================================
Really nice commands to remember:
:g/string/# show all lines with string in them with line numbers
:1,$g/^$/d delete all blank lines from line 1 to $ (end of file)
:1,$g/ */s// /g replace multiple spaces with one space
:[range]g/[string]/d"a delete (or yank) lines containing
string into buffer a
:[range]g!/[string]/d"a delete lines NOT containing string into
buffer a
:-m. or .m+ switch current line with previous|next
:f newbuffername change name of file being edited to a new name
==============================================================================
INTERFACING WITH SAVED FILES (FILES -NOT- IN EDITOR BUFFER(S))
:w filename SAVE ENTIRE buffer to a new file
:'a;'bw filename SAVING PART of buffer to a new file
:'a;'bw! filename OVERWRITING a file with part of buffer
:'a;'bw >>filename appending part of buffer to a file
:r filename reading in a filename at CP
==============================================================================
SHELL INTERFACING
:r!cmd output of command written into edit file at CP
:'a;'b!cmd filter lines thru command(use text as input to
command, replace text with output of command)
cb,pr -o1,cut,paste,expand and many other
filters can add almost any command to vi
:w!cmd write lines to standard input of command
:w! lpr -Pps (or lp -dps)
:!cmd execute single shell command
:sh execute multiple shell commands (start a subshell)
==============================================================================
:g/^/m 0 # reverse a file
==============================================================================