Vim Cheat Sheet

A comprehensive reference for Vim editor commands and shortcuts

Modes

N i

Enter Insert mode

I Esc

Exit Insert mode (return to Normal mode)

N v

Enter Visual mode

N V

Enter Visual Line mode

N Ctrl+v

Enter Visual Block mode

N :

Enter Command-line mode

File Operations

C :w

Save file

C :q

Quit

C :wq

Save and quit

C :q!

Quit without saving

C :e filename

Open file

C :w filename

Save as

Inserting Text

N i

Insert before cursor

N I

Insert at beginning of line

N a

Append after cursor

N A

Append at end of line

N o

Open new line below current line

N O

Open new line above current line

Deleting Text

N x

Delete character under cursor

N X

Delete character before cursor

N dw

Delete word

N dd

Delete entire line

N D

Delete from cursor to end of line

N d$

Delete to end of line

N d0

Delete to beginning of line

Changing Text

N r

Replace a single character

N cw

Change word

N cc

Change entire line

N C

Change from cursor to end of line

N s

Substitute character (delete and insert)

N S

Substitute line (delete and insert)

Copy & Paste

N yy

Yank (copy) entire line

N yw

Yank (copy) word

N p

Paste after cursor

N P

Paste before cursor

Undo & Redo

N u

Undo

N Ctrl+r

Redo

Visual Selections

N v

Start Visual character mode

N V

Start Visual line mode

N Ctrl+v

Start Visual block mode

V o

Move to other end of selection

V Esc

Exit Visual mode

Operations in Visual Mode

V d

Delete selected text

V y

Yank (copy) selected text

V c

Change selected text

V >

Indent selected text

V <

Un-indent selected text

V ~

Toggle case of selected text

Markers & Jumps

N ma

Set mark 'a' at cursor position

N `a

Jump to mark 'a'

N 'a

Jump to beginning of line of mark 'a'

N Ctrl+o

Jump to previous location

N Ctrl+i

Jump to next location

Folding

N zf{motion}

Create fold

N zo

Open fold

N zc

Close fold

N za

Toggle fold

N zR

Open all folds

N zM

Close all folds

Macros

N qa

Record macro 'a'

N q

Stop recording macro

N @a

Execute macro 'a'

N @@

Execute last used macro

Windows & Tabs

C :sp

Split window horizontally

C :vsp

Split window vertically

N Ctrl+w s

Split window horizontally

N Ctrl+w v

Split window vertically

N Ctrl+w w

Switch between windows

N Ctrl+w q

Quit current window

C :tabnew

Create new tab

C :tabn

Go to next tab

C :tabp

Go to previous tab