Cheatsheet: Getting Started
Cheatsheet: Getting Started
me/vim
Vim cheatsheet
A useful collection of Vim 8.2 quick reference cheat sheets to help you learn vim editor faster.
# Getting started
Motion Diagrams Motions Insert Mode
1 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
:w Save
:q Close file
Save
:wq | :x | ZZ
and quit
Save
:wqa and quit
all files
Force
:q! | ZQ
quit
Close all
:qa
files
Force
:qa! quit all
files
Write to
:w new.txt
new.txt
Save
:sav new.txt and edit
new.txt
Write to
:w !sudo tee % readonly
file
2 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
Delete line
dd
Join
Usage with (Cut)
Available Operators Examples
J
next line
d w d Delete
Swap two Combination Description
ddp
Redo lines
Operator Motion y Yank (copy) Delete
changes dd
<C-r> / 5 <C-r> Yank line current line
1 yy Change
c (Copy)
times Delete two
dj
Paste from lines
p"*p | "+p Paste
system
Delete to next
Visual mode clipboard dw Macros
= Formats code word
Enter visual Paste to qi Record macro i
v
Combine operators with mode g~ Toggle case Delete to
"*y | "+y system
motions to use them db beginning
Stop of
recording
clipboard q
Enter visual line gU Uppercase word
macro
V
mode In visual mode
gu Lowercase @i Delete until a
Run macro i
Delete selection dfa
Enter visual d | x char
<C-v>
block mode > Indent(Cut)
right Run macro i 7
7@i
Deletetimes
until
Replace d/hello
ggVG Select all text <s Indent left hello
selection @@ Repeat last macro
Shift text Filter through external Change
> / < ! Yank selection cc
right/left y program current line
(Copy)
Copy current
yy
line
Delete a
ggdG complete
document
Indent a
3 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
Counts
#d3w
Text objects
Delete 3 words
Delete 5 lines
d5j Usage Text objects Delete
downwards
i/ p Paragraph diw Delete inner word
v p
a Indent 4 lines
>4k w Word
upwards dis Delete inner sentence
inner / Text
Operator WORD
around object di" Delete in quotes
W
Delete in quotes
da"
(including quotes)
Operate with an operator inner s Sentence
or around text blocks dip Delete a paragraph
[({< A [], (), or {} block
Select inner quotes '"` A quoted string ciw Change inner word
vi"
"..."
b A block [( ci" Change inner quotes
va" Select quotes "..."
B A block in [{ Change inner tags
cit
Select inner brackets (HTML)
vi[
[...] t A HTML tag block
Change inner
cip
Select brackets paragraph
va[
[...]
yip Yank inner paragraph
viw Select inner word
Yank paragraph
yap
Select inner (including newline)
vip
paragraph
Select more
vipip See :help text-objects
paragraph
# Multiple files
4 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
gt Go to next tab
gT Go to previous tab
5 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
Search :[range]s/{pattern}/{str}/[flags]
:%s/{pattern}/{str}/[flags]
/foo
forward
Replace Replace
:s/old/new/g :%s/old/new/g
Search all all
?foo
backward
Replace Replace
Search with :s/\vold/new/g all with :%s/old/new/gc all
/\v\d+ regex (Confirm)
regex
Copy lines
:g/foo/t$ containing
foo to EOF
Move lines
6 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
Flags
i Ignore case
Confirm each
c
substitution
7 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
Jumping
]c Next difference
[c Previous difference
# Miscellaneous
Case Jumping Misc command-lines
Lowercase
Vu / guu Enable
line
Insert
:set paste
Paste
Toggle case
V~ / g~~ sub-mode
line
disable
Uppercase
gggUG Insert
all text :set nopaste
Paste
Lowercase sub-mode
ggguG
all text
Exiting
Toggle case with an
ggg~G :cq error
all text
8 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
Navigating
Nearest/matching
%
Previous
[( | [{ | [<
]) | ]{ | ]> Next
Previous method
[m
Previous method
[M
Counters Tags
Right-align lines at
:ri 4 Find definitions of Classname (auto-
4 columns :tjump Classname
select 1st)
Marks Calculator
'' Back to line in current buffer where jumped from Do this in INSERT mode
9 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
Shell
Interpret
:!<shell> Shell
Command
Read in
:r!<shell> output of
shell
Replace
:!!date current line
with date
Command line
Insert
current
word into
<C-r><C-w>
the
command
line
Paste from
<C-r>"
" register
Auto-
completion
<C-x><C-f> of path in
insert
mode
_ Tricks
10 of 11 2/10/21, 11:04 AM
Vim - Quick Reference Cheat Sheet https://quickref.me/vim
11 of 11 2/10/21, 11:04 AM