Vim tips & shortcuts.

i                 => insert before current letter; go into insert mode from command mode
a                 => insert after current letter; go into insert mode from command mode
I                 => insert at beginning of current line
A                 => insert at end of current line
o                 => add new line below current line
O                 => add new line above current line
u                 => undo
ctrl+r            => redo undo
r                 => replace
v                 => visual mode
:                 => command mode
:set number       => show line number
:set nonumber     => hide line number
cc                => change/replace entire line, same as S
cw                => change/replace the word
c$                => change/replace to the end of current line
dw                => delete a word
d$                => delete until end of current line, same as D
dG                => delete until end of current file
dd                => delete current line
ndd               => delete n lines (where n is number of lines)
yy                => copy current line
nyy               => copy n lines
yw                => copy word
ve                => select to end of word
y$                => copy to end of line
y0                => copy to start of line
p                 => paste copied after cursor
P                 => paste copied before cursor
x                 => delete from current letter and forward (including current letter)
X                 => delete from current letter and afterward (excluding current letter)
ESC               => go into command mode from insert mode
h                 => move left
l                 => move right
j                 => move down
k                 => move up
N[hljk]           => move N letters left/right; move N lines down/up
$                 => move to end of current line
0                 => move to start of current line (zero, not O)
w                 => move word forward (including whitespace)
e                 => move word forward (excluding whitespace)
ctrl+f            => move page forward
ctrl+b            => move page back
G                 => move to bottom of file
gg                => move to start of file
nG                => move n lines forward
J                 => delete the line break at the end of current line
>                 => shift text right
<                 => shift text left
:lineno           => go to number line
ctrl+g            => show current location and file status
:w                => write/save
:q                => quite
:q!               => quite without saving changes, same as ZQ
:wq               => quite and write/save, same as ZZ or :x
ctrl+v            => column/block selection
/                 => search forward; n => repeat search forward; N => repeat search backward
?                 => search backward; n => repeat search forward; N => repeat search backward
:s/old/new/g      => substitute old with new for all occurrences in the line
:%s/old/new/g     => substitute old with new for all occurrences in the file
:%s/old/new/gc    => substitute old with new for all occurrences in the file with confirmation prompt
:s/old/new        => substitute old with new for first occurrence in the line
:#,#s/old/new/g   => substitute old with new for all occurrences in lines #,# (range)

References

BACK TO TOP
Post tagged with: vim