{ ILoveJS }

Vim Commands Cheatsheet

vim

Essential Vim/Neovim commands for developers.

8 sections · 70 items

Modes

Normal Mode
Esc

Default mode for navigation and commands; press Esc from any mode to return

typescript
Esc
Insert Mode
i

Enter insert mode at cursor position to type text

typescript
i
Visual Mode
v

Enter visual mode to select text character by character

typescript
v
Command Mode
:

Enter command-line mode to execute Ex commands

typescript
:w

Movement

Left
h

Move cursor one character left

Down
j

Move cursor one line down

Up
k

Move cursor one line up

Right
l

Move cursor one character right

Word Forward
w

Move cursor to start of next word

Word Backward
b

Move cursor to start of previous word

End of Word
e

Move cursor to end of current or next word

Line Start
0

Move cursor to beginning of line

Line End
$

Move cursor to end of line

File Start
gg

Move cursor to first line of file

File End
G

Move cursor to last line of file

Half Page Down
Ctrl+d

Scroll down half a page

Half Page Up
Ctrl+u

Scroll up half a page

Paragraph Back
{

Move to previous paragraph or blank line

Paragraph Forward
}

Move to next paragraph or blank line

Matching Bracket
%

Jump to matching bracket or parenthesis

Editing

Insert at Cursor
i

Enter insert mode before cursor

Append After Cursor
a

Enter insert mode after cursor

Open Line Below
o

Insert new line below and enter insert mode

Insert at Line Start
I

Enter insert mode at first non-blank character of line

Append at Line End
A

Enter insert mode at end of line

Open Line Above
O

Insert new line above and enter insert mode

Delete Character
x

Delete character under cursor

Delete Line
dd

Delete entire current line

Yank Line
yy

Copy entire current line to register

Paste After
p

Paste content after cursor or below current line

Paste Before
P

Paste content before cursor or above current line

Undo
u

Undo last change

Redo
Ctrl+r

Redo last undone change

Repeat Last Command
.

Repeat the last editing command

Text Objects

Delete Word
dw

Delete from cursor to start of next word

Delete Inner Word
diw

Delete entire word under cursor without surrounding spaces

Delete Around Quotes
da"

Delete text including surrounding double quotes

Delete Inside Quotes
di"

Delete text inside double quotes without quotes

Delete Till Character
dt,

Delete from cursor up to but not including specified character

typescript
dt,
Change Inside Braces
ci{

Delete content inside curly braces and enter insert mode

Change Around Brackets
ca[

Delete content including square brackets and enter insert mode

Yank Inside Parentheses
yi(

Copy text inside parentheses to register

Delete Inside Tag
dit

Delete content inside HTML or XML tag

Visual Mode

Character Visual
v

Start visual mode for character-wise selection

Line Visual
V

Start visual mode for line-wise selection

Block Visual
Ctrl+v

Start visual block mode for column selection

Reselect Last
gv

Reselect the last visual selection

Search and Replace

Search Forward
/pattern

Search forward for pattern

typescript
/function
Search Backward
?pattern

Search backward for pattern

typescript
?const
Next Match
n

Jump to next search match

Previous Match
N

Jump to previous search match

Search Word Forward
*

Search forward for word under cursor

Search Word Backward
#

Search backward for word under cursor

Global Replace
:%s/old/new/g

Replace all occurrences of old with new in file

typescript
:%s/foo/bar/g
Replace with Confirm
:%s/old/new/gc

Replace all with confirmation prompt for each match

typescript
:%s/foo/bar/gc

File Operations

Save File
:w

Write current buffer to file

Quit
:q

Quit current window

Save and Quit
:wq

Write file and quit

Force Quit
:q!

Quit without saving changes

Edit File
:e filename

Open file for editing

typescript
:e index.js
Vertical Split
:vs filename

Open file in vertical split window

typescript
:vs app.js
Horizontal Split
:sp filename

Open file in horizontal split window

typescript
:sp utils.js

Macros and Marks

Record Macro
qa

Start recording macro into register a

typescript
qa
Stop Recording
q

Stop recording current macro

Play Macro
@a

Execute macro stored in register a

typescript
@a
Repeat Last Macro
@@

Execute the last played macro again

Set Mark
ma

Set mark a at current cursor position

typescript
ma
Jump to Mark
`a

Jump to exact position of mark a

typescript
`a
Jump to Mark Line
'a

Jump to beginning of line containing mark a

typescript
'a
List Marks
:marks

Display list of all current marks

Related Content