Skip to main content

An outline of the vi(m) functions you can utilise whilst in command mode - yes they are case sensitive

action outcome
a change to insert mode (after cursor)
A change to insert mode (at end of line)
dd delete one line
G go to end of the file
1G go to top of the file
i change to insert mode (before cursor)
J merge next line with this one
p paste deleted or yanked text after cursor
P paste deleted or yanked text before cursor
r replace one character
R overwrite text
x delete one character
yy yank line (copy)

 

/ search, follow / with text to find
{esc}:wq! write file and quit
{esc}:q! quit without saving
%s/old/new/g substitute; replace "old" with "new" on all lines
:g/pattern/d delete all lines that match the pattern

 

Note: when editing a file and the permission is 444 or r--r--r--, to save the file you need to add an exclamation mark... for example :wq!