Show Menu
Cheatography

Yet Another Vim Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Navigation

[}
begin of { } block
]}
end of { } block
[(
open parent­hesis of current ()
])
close parent­hesis of current ()

Splits | Tabs

C-w w
Switch to other split window
C-w =
Resize to equal
C-w < or >
Resize by 10 col (vsplit)
C-w + or -
Resize by 10 lines (hsplit)
C-w c
Close current window
C-w x
Invert window with next one
C-w C-f
Open file (cursor) in split
C-w gf
Open file (cursor) in tab
:ls
list buffers
:vert sb N
open vsplit with buffer N
:vsplit /path/­to/file
open file in vsplit
set scroll­bind!
toggle scroll together
:tab ball
All buffers to tabs

vimdiff

]c
Jump to next diff
[c
Jump to previous diff
do
Merge change from other win
dp
Merge change to other win
:diffthis
In both vsplit that wanting to diff
:diffu­pdate
Recompute diff
:DirDiff <pa­th1> <pa­th2>
Recurse diff two path
"­oth­er" = where pointer is not

Space to tab

:set tabstop=4
:set noexpandtab
:%retab!

Tab to space

:set tabstop=4
:set expandtab
:%retab

Vimgrep

:vimgrep /<p­att­ern­>/ <fi­les>
grep <pa­tte­rn> in <fi­les>
:vimgrep /<p­att­ern> %
grep <pa­tte­rn> in current file
:copen
Open quickfix list (contain grep results)
 

Useful shortcuts

g C-g (visual)
Count
o (visual)
move to other end of selection
:tab ball
convert all buffers to tabs
q[a-z] ... q
start/stop recording in registry a-z
@[a-z]
replay recording a-z
"­[a-­z]y­y/dd/p
copy/c­ut/­paste registry a-z
"­*yy­/dd/p
copy/c­ut/­paste system clipboard
C-<pg up>­/<pg down>
next tab
:read !<c­omm­and>
insert output of command
:read <fi­le>
insert file content
<F3>
Explore files (netrw)
*
Search current word
set ff=(do­s|unix)
eol = (dos|unix)
gf
goto file: open file at cursor path

Regex

:g/<pa­tte­rn>/d_
delete all line matching pattern
(<p­att­ern­>)­\@<=
lookbehind (positive)
(<p­att­ern­>)­\@<!
lookbehind (negative)
(<p­att­ern­>)\@=
lookahead (positive)
(<p­att­ern­>)\@!
lookahead (negative)
:s/<pa­tte­rn>/new &/
Replace pattern by "new patter­n"
:s/<pa­tte­rn>­/\=@a/
Replace pattern by content of a register

NetRw Dir explorer

i
cycle listing mode
<de­l>
Remove
<F1>
Show help

XML

vat
select whole tag (<t­ag>...<­/t­ag>)

Spell

z=
see sugges­tions
zg
add to good list
zw
add to wrong list
zug
remove from good list
zuw
remove from wrong list
]s
go to next
[s
go to previous