xutil.dev
Login

Vim Cheatsheet

Quick reference for Vim commands covering modes, movement, editing, search/replace, file operations, window management, visual mode, and macros

93 commands

i

Enter insert mode before cursor

a

Enter insert mode after cursor

I

Insert at beginning of line

A

Append at end of line

o

Open new line below and insert

O

Open new line above and insert

Esc

Return to normal mode

v

Enter visual mode (character)

V

Enter visual mode (line)

Ctrl-v

Enter visual block mode

R

Enter replace mode

h / j / k / l

Move left/down/up/right

w

Move to next word start

b

Move to previous word start

e

Move to end of word

0

Move to beginning of line

$

Move to end of line

^

Move to first non-blank character

gg

Go to first line of file

G

Go to last line of file

:{n}

Go to line number n

Ctrl-f

Scroll down one page

Ctrl-b

Scroll up one page

%

Jump to matching bracket

f{char}

Jump to next char in line

t{char}

Jump to before next char in line

x

Delete character under cursor

dd

Delete (cut) entire line

dw

Delete word

d$

Delete to end of line

d0

Delete to beginning of line

yy

Yank (copy) entire line

yw

Yank word

p

Paste after cursor

P

Paste before cursor

u

Undo last change

Ctrl-r

Redo last undo

r{char}

Replace character under cursor

cc

Change entire line

cw

Change word

C

Change to end of line

J

Join line below to current

~

Toggle case of character

>>

Indent line

<<

Unindent line

.

Repeat last command

/{pattern}

Search forward for pattern

?{pattern}

Search backward for pattern

n

Move to next search match

N

Move to previous search match

:s/old/new/

Replace first match in current line

:s/old/new/g

Replace all matches in current line

:%s/old/new/g

Replace all matches in file

:%s/old/new/gc

Replace all in file with confirmation

*

Search forward for word under cursor

#

Search backward for word under cursor

:noh

Clear search highlighting

:w

Save file

:w {file}

Save as specified filename

:q

Quit

:q!

Force quit without saving

:wq

Save and quit

:x

Save and quit (if modified)

ZZ

Save and quit (same as :x)

:e {file}

Open file for editing

:r {file}

Insert file contents

:set number

Show line numbers

:set paste

Enable paste mode

:set syntax=on

Enable syntax highlighting

:split

Horizontal split

:vsplit

Vertical split

Ctrl-w w

Switch to next window

Ctrl-w h/j/k/l

Move to window in direction

Ctrl-w =

Equalize window sizes

Ctrl-w q

Close current window

:tabnew

Open new tab

gt

Go to next tab

gT

Go to previous tab

:tabclose

Close current tab

v + motion

Select characters then operate

V + motion

Select lines then operate

d (visual)

Delete selection

y (visual)

Yank selection

> (visual)

Indent selection

< (visual)

Unindent selection

gv

Reselect last visual selection

q{reg}

Start recording macro to register

q

Stop recording macro

@{reg}

Play back macro from register

@@

Replay last macro

"{reg}y

Yank to named register

"{reg}p

Paste from named register

:reg

Show all register contents