vim
vim is a modal text editor
Vi epitomises all that is great about the UNIX way of thinking. It has a very steep learning curve and without takling time to learn the commands a new user would get lost very quickly. However, with a bit of effort you will soon have the most powerful and efficient text editor at your fingertips.
See here for a vi command reference.
See here for a vim cheat sheet.
Tips
- Use the
%key to jump to a matching bracket. - Use
set noautoindentto prevent indentation problems when pasting into vim. - Use
set fileformat=unixto remove DOS CR characters. - Use
set background=darkwhen using vim in a terminal with a dark background.
Examples
Regular expressions
:g/^\s*$/d # delete all blank lines :g!/string/d # delete lines not containing string :g/fred/,/joe/d # delete across lines