vim cheat sheet



0         ^                                       %          $
          word worditty wordyword( wordly( word ) ) // wordric
               b←    →e     *→         fl (←F repeat: ;→ ,←)   
G

%s/orig\c/replace/gc
↑      ↑↑          ↑
file   case insen. confirm


search delimiters

^  \<         \>  $
 ... wordyword ...

Buffers
KeyCommand
:lslist buffers
Ctrl+6go to alt buffer
:bpGo back
:bnGo forward
:bd #Delete buffer
:e nameEdit file
gf
^w,f
Goto file
(F) at pos

KeyCommand
Ctrl+w nNew buffer
Ctrl+w,vVert split
Ctrl+w,sHoriz split
Ctrl+w,qClose
Ctrl+w,oClose others
Ctrl+w,KMove up
Ctrl+w,+ >Reize
:new | r! grep -nrI pat
:new | r! git blame ^r%

Folding / Diff
KeyCommand
zM zRFold/Unfold all
zaFold/Unfold
zo zcOpen/Close fold
]cNext change
[cPrev change
doDiff get
dpDiff put
$ P4DIFF=vimdiff p4 …
:windo set wrap

Mark (' or `)
KeyCommand
m[a-z`]Set mark at pos
`[a-z`]Jump to mark
Ctrl+oGo back
Ctrl+iGo forward
`.Last change pos
g;Last change pos
g,Next change pos

Visual Mode
KeyCommand
v or VEnter visual mode
EscExit visual mode
< or >Shift text
y/^r"find selection
yq/pfind selection
^VI#[esc]

CTags
KeyCommand
g,Ctrl+]Goto or list
Ctrl+]Go to tag
g]List tags
Ctrl+tJump back

Line Change
KeyCommand
CChange to eol
ccChange the line
DDelete to eol
A or IAppend/Insert

Undo
KeyCommand
u or UUndo (Line)
Ctrl+rRedo

KeyCommand
yiwyank inner word
viwpselect, replace
viw"0pthird time
Vpreplace line

Autocomplete
KeyCommand
^x,^oOmni complete
^x,^]CTags complete
^nprev or nav down
^pnext or nav up
^ecancel
:pcpreview close
^wzpreview close

Misc
KeyCommand
:!%execute filename
:r!%read into buffer
>aBIndent a Block
cs findcscope find
^r,^wword at cursor
:cs find s ^r^w

© 2011, 2018 David Blume