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 parenthesis of current () |
]) |
close parenthesis 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 scrollbind! |
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 |
:diffupdate |
Recompute diff |
:DirDiff <path1> <path2> |
Recurse diff two path |
"other" = where pointer is not
Space to tab
:set tabstop=4
:set noexpandtab
:%retab!
|
Tab to space
:set tabstop=4
:set expandtab
:%retab
|
Vimgrep
:vimgrep /<pattern>/ <files> |
grep <pattern> in <files> |
:vimgrep /<pattern> % |
grep <pattern> 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]yy/dd/p |
copy/cut/paste registry a-z |
"*yy/dd/p |
copy/cut/paste system clipboard |
C-<pg up>/<pg down> |
next tab |
:read !<command> |
insert output of command |
:read <file> |
insert file content |
<F3> |
Explore files (netrw) |
* |
Search current word |
set ff=(dos|unix) |
eol = (dos|unix) |
gf |
goto file: open file at cursor path |
Regex
:g/<pattern>/d_ |
delete all line matching pattern |
(<pattern>)\@<= |
lookbehind (positive) |
(<pattern>)\@<! |
lookbehind (negative) |
(<pattern>)\@= |
lookahead (positive) |
(<pattern>)\@! |
lookahead (negative) |
:s/<pattern>/new &/ |
Replace pattern by "new pattern" |
:s/<pattern>/\=@a/ |
Replace pattern by content of a register |
NetRw Dir explorer
i |
cycle listing mode |
<del> |
Remove |
<F1> |
Show help |
XML
vat |
select whole tag (<tag>...</tag>) |
Spell
z= |
see suggestions |
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 |
|