🏠 Home›Cheatsheets›Vim

✏️ Vim Cheatsheet

Vim editor commands and shortcuts

Mode Switching

Insert Mode

i

Enter insert mode at cursor

Mode Switching

Insert at Line Start

I

Enter insert mode at line start

Mode Switching

Append

a

Enter insert mode after cursor

Mode Switching

Append at Line End

A

Enter insert mode at line end

Mode Switching

New Line Below

o

Create new line below and enter insert mode

Mode Switching

New Line Above

O

Create new line above and enter insert mode

Mode Switching

Exit Insert Mode

Esc

Return to normal mode

Navigation

Move Left

h

Move cursor left

Navigation

Move Down

j

Move cursor down

Navigation

Move Up

k

Move cursor up

Navigation

Move Right

l

Move cursor right

Navigation

Beginning of Line

0

Jump to start of line

Navigation

End of Line

$

Jump to end of line

Navigation

Next Word

w

Jump to start of next word

Navigation

Previous Word

b

Jump to start of previous word

Navigation

Start of File

gg

Jump to beginning of file

Navigation

End of File

G

Jump to end of file

Navigation

Go to Line

:line_number

Jump to specific line number

Editing

Delete Character

x

Delete character at cursor

Editing

Delete Word

dw

Delete word

Editing

Delete Line

dd

Delete entire line

Editing

Delete to End

D

Delete to end of line

Editing

Undo

u

Undo last change

Editing

Redo

Ctrl+r

Redo change

Editing

Copy Line

yy

Copy entire line

Editing

Copy Word

yw

Copy word

Editing

Paste After

p

Paste after cursor

Editing

Paste Before

P

Paste before cursor

Search

Find Forward

/pattern

Search forward for pattern

Search

Find Backward

?pattern

Search backward for pattern

Search

Next Match

n

Jump to next search match

Search

Previous Match

N

Jump to previous search match

Replace

Replace in Line

:s/old/new

Replace first occurrence in line

Replace

Replace All in Line

:s/old/new/g

Replace all occurrences in line

Replace

Replace in File

:%s/old/new/g

Replace all occurrences in file

File Operations

Save File

:w

Write/save file

File Operations

Save and Exit

:wq

Save file and exit vim

File Operations

Exit Without Save

:q!

Quit without saving

File Operations

Save As

:w filename

Save file with new name

More in this category

|🏠 Home|
|