VIM: Vi IMproved!

AmigaOS, AtariMiNT, BeOS, DOS, MacOS, MachTen, OS/2, RiscOS, VMS, and Windows (95/98/NT4/NT5/2000), A/UX, AIX, BSDI, Convex, DYNIX/ptx, DG/UX, DEC Unix, FreeBSD, HPUX, Irix, Linux [Debian, RedHat, Slackware, SuSE,...], MacOSX, NetBSD, NEXTSTEP, OpenBSD, OSF, QNX, SCO, Sinix, Solaris, SunOS, SUPER-UX, Ultrix, Unixware, Unisys...

Modes

Navigating in command mode

While navigating in command mode, use the vi keys:

    k
h     l
    j



hjkl: left, down, up, right

This configuration keeps your fingers on those home keys. You can also use the standard arrow keys. Command mode is the default when you enter vim, but if you want to enter it at any time, press esc.

Operations in command mode

More commands



vim supports repeated commands. To repeat a command x times, enter the number of times before the command.

Example: to move down 5 lines, enter:

5j

in command mode.

Searching

To enter a search string, hit the / (slash) key while in command mode.

To substitute one string for another, enter this:

:s/string_to_replace/new_string/

This replaces string_to_replace with new_string if it is found on the line where the cursor is located. The above command will only replace one isntance. To replace all instances on that line, add a g to the end of the command. To do a case-insensitive match, add an i to the command. Like this:

:s/string_to_replace/new_string/gi

To replace very instance in the entire file, use this command:

:%s/string_to_replace/new_string/

vim supports regular expressions for searching and replacing.

Programmers' Friends



Examples...

Example .vimrc file:

set smartindent
set backspace=0
set ruler
set noshowcmd
set noshowmode
set nobackup
set shiftwidth=4
set showmatch
set noautoindent
set writeany
set incsearch




Presented for the Computer Club at WMU by Wesley Leonard on September 27th, 2001.

Resources: The vim homepage
Learning the vi editor published by O'Reilly & Associates