Vim Cheatsheet¶
Note that this cheatsheet is almost completely based on my lunarvim configuration and may only be intended for my personal use.
Navigation¶
h
j
k
l
: left / down / up / rightw
b
: next / previous wordgg
G
: top / bottom of file0
$
: beginning / end of line^
: first non-blank character of line<C-d>
<C-u>
: half page down / up<C-f>
<C-b>
: full page down / upzt
zz
zb
: scroll cursor to top / middle / bottom of screen%
: jump to matching bracket
Editing¶
i
a
: insert before / after cursorI
A
: insert at beginning / end of lineo
O
: insert new line below / abovex
: delete character under cursorrW
: replace character under cursor withW
R
: start replace modecw
: change wordc$
: change to end of linecc
: change linedd
: delete lineu
<C-r>
: undo / redo~
: switch case of character under cursory
: copy textp
: paste after cursor
Search¶
/
: search forward?
: search backwardn
N
: next / previous match*
#
: search for word under cursor forward / backwardgd
: go to definition of word under cursorgi
: go to last insert position
Visual¶
v
: start visual modeV
: start visual line mode<C-v>
: start visual block modegv
: re-select last visual selectiono
: move to other end of highlighted texta"
a'
a(
a[
a{
: select matching blocki"
i'
i(
i[
i{
: select inner matching block
Substitution¶
:s/foo/bar/
: replace firstfoo
withbar
in current line:%s/foo/bar/
: replace firstfoo
withbar
in file
Flags:
- No flag: replace first occurrence
g
: replace all occurrencesc
: confirm before replacei
: case-insensitiveI
: case-sensitive
Last update:
2023-11-19
Created: 2023-11-19
Created: 2023-11-19