New to Vim?
Welcome to Vim! Here are some tips to get you started:
- To enter command mode in Vim, press Esc, then type a colon :
- To exit Vim, enter command mode and type :q (or :q! to exit without saving)
- Don't worry if it feels confusing at first. Vim has a learning curve, but it's worth it!
Vim Commands
Essential
:q
Quit (close window)
:q!
Quit and throw away unsaved changes
:w
Save (write) the file, but don't exit
:wq
Save and quit
i
Switch to insert mode
Esc
Switch to command mode
Navigation
h
Move cursor left
j
Move cursor down
k
Move cursor up
l
Move cursor right
w
Jump forwards to the start of a word
b
Jump backwards to the start of a word
e
Jump forwards to the end of a word
0
Jump to the start of the line
$
Jump to the end of the line
gg
Go to the first line of the document
G
Go to the last line of the document
{
Jump to previous paragraph
}
Jump to next paragraph
Ctrl+u
Move up half a screen
Ctrl+d
Move down half a screen
Editing
x
Delete character at cursor
dw
Delete word
dd
Delete line
D
Delete from cursor to end of line
yy
Yank (copy) a line
yw
Yank (copy) word
p
Paste after cursor
P
Paste before cursor
u
Undo
Ctrl + r
Redo
r
Replace a single character
cw
Change (replace) to the end of the word
cc
Change (replace) entire line
c$
Change (replace) to the end of the line
~
Switch case of the character under the cursor
Searching
/pattern
Search forward for pattern
?pattern
Search backward for pattern
n
Repeat search in same direction
N
Repeat search in opposite direction
*
Search forward for word under cursor
#
Search backward for word under cursor
:%s/old/new/g
Replace all old with new throughout file
:%s/old/new/gc
Replace all old with new throughout file with confirmations
Visual Mode
v
Start visual mode, mark lines, then do a command (like y-yank)
V
Start linewise visual mode
Ctrl+v
Start visual block mode
o
Move to other end of marked area
O
Move to other corner of block
aw
Mark a word
ab
A block with ()
aB
A block with {}
ib
Inner block with ()
iB
Inner block with {}
File Operations
:e filename
Edit a file in a new buffer
:bnext
Go to the next buffer
:bprev
Go to the previous buffer
:bd
Delete a buffer (close a file)
:sp filename
Open a file in a new buffer and split window
:vsp filename
Open a file in a new buffer and vertically split window
Ctrl+ws
Split window
Ctrl+ww
Switch windows
Ctrl+wq
Quit a window
Ctrl+wv
Split window vertically
About VimLeap
VimLeap is a beginner-friendly Vim cheat sheet designed to help newcomers get started with Vim. We aim to make learning Vim less intimidating and more accessible.
Have suggestions or feedback? Email us at: emah84@gmail.com