Vim is the improved vi editor. Documentation and FAQ
It can be expanded with scripts and plugins.


you can run vim in the terminal, or use the gvim gui with its menus/toolbar - and the first thing to do, Edit > Color scheme

There's also cream - gui editor based on vim

Vim keys

Moving about
cursors, home, end,
pg up, pg dn
move about
..or h,j,k,l, 0, $, Ctrl-b, Ctrl-f
Space move right
Bkspace moves left
return go to start of next line
Ctrl-d move down half page
Ctrl-u move up half page
G move to file end
n G move to line n
H move to file begin
10w move along 10 words
8 enter move down 8 lines
( and ) move to next sentence start (new para, or punct mark and two space defined)
Enter edit modes with
a app mode -at after cursor
i ins mode -at bef cursor
s ins replace char
S or cc replace line
R type over line
o ins new line
O ins new line above
3i enter insert mode, type, escape then entered text repeated 3 times
delete remove char but not lines
U restore line
esc to return to command mode
cw change word - enter new text, escape
In command mode
x to delete char
Ctrl-D to delete to end of line
dd to cut line, u to undo/redo
yy to copy the line, p to paste in
w moves by word, W moves by space delimited word
dw deletes word
70dw deletes 70 words (a way to last lines of file)
s/old/new/ replaces 'old' with 'new' on current line, add g on end to replace all
1,$ s/old/new/g replaces every occurance, from line 1 to last line
Select text
V start select by line
cursors add to selected
d cuts selected
y yanks selected
p inserts cut/yanked
Ctrl-V start select (geometric)
d then removes selected (geometric) -but leaves the lines
D removes all text on selected lines -but leaves the lines
y yanks
p inserts the cut text
(my Ctrl-[ and Ctrl-] work to copy and paste selection too, using xsel - see my Urxvt page)
/ pattern search fwd
? pattern search backwd
n search next fwd
N search next backwd
Opening files
vi -R file read only mode
vi +s file open at file end
vi +12 file open at line 12
vi +/book open file at pattern "book"
:r filename insert file
:e filename Stop editing the current file and edit the specified file.
:n Stop editing the current file and edit the next file specified on the command line
:q Quit (can't if changed file)
:q! Quit no write out
:w write the file to disk (can't if file yet unnamed)
:wq write and quit
:w filename Save the file with new filename
:wa write all files to disk
:abbreviate teh the enter abbreviate a miss-spelling
:map Ctrl-v <new key> <vi key> enter add mapping
:map enter show key mapping
:unmap Ctrl-v <map key> enter remove a mapping
:! enter bash prompt
!! <unix command> bash output added to file
Ctrl-S freeze file
Ctrl-Q resume edit
Ctrl-G file info
During a process
Ctrl-z to stop (send to bg) -same as & on end of bash command
fg to bring to foregr.
bg to list bg jobs
fg %n bring to foregr. job n
jobs to list all active bash progs?
ps -g|-x|-u (etc) to list active processes
kill %n kill job n
kill (PID) kill process of PID no.

Turn on syntax colourisation for recognised file types
and uncomment the syntax line - Down, i, delete, escape, :wq

using vi

advanced vi