- | - |
---|---|
qi |
Record macro i |
q |
Stop recording macro |
@i |
Run macro i |
7@i |
Run macro i 7 times |
@@ |
Repeat last macro |
You can save macro for any letters not just i |
Getting Started
Macros
Visual mode
Shortcut | Description |
---|---|
v |
Enter visual mode |
V |
Enter visual line mode |
<C-v> |
Enter visual block mode |
ggVG |
Select all text |
> / < |
Shift text right/left |
Repeating
Shortcut | Description |
---|---|
. |
Repeat last command |
; |
Repeat latest f , t , F or T |
, |
Repeat latest f , t , F or T reversed |
& |
Repeat last :s |
@: |
Repeat a command-line command |
Cut and paste
Shortcut | Description |
---|---|
x |
Delete character (Cut) |
p / P |
Paste after/before |
xp |
Swap two characters |
D |
Delete to end of line (Cut) |
dw |
Delete word (Cut) |
dd |
Delete line (Cut) |
ddp |
Swap two lines |
yy |
Yank line (Copy) |
"*p * |
* "+p |
"*y * |
* "+y |
#In visual mode
Shortcut | Description |
---|---|
d * |
* x |
s |
Replace selection |
y |
Yank selection (Copy) |
Normal Mode
Shortcut | Description |
---|---|
r |
Replace one character |
R |
Enter Replace mode |
u / 3u |
Undo changes 1 / 3 times |
U |
Undo changes on one line |
J |
Join with next line |
<C-r> / 5 <C-r> |
Redo changes 1 / 5 times |
Saving and Exiting
Shortcut | Description |
---|---|
:w |
Save |
:q |
Close file |
:wq * |
* :x * |
:wqa |
Save and quit all files |
:q! * |
* ZQ |
:qa |
Close all files |
:qa! |
Force quit all files |
:w now.txt |
Write to now.txt |
:sav new.txt |
Save and edit new.txt |
:w !sudo tee % |
Write to readonly file |
Insert Mode
Shortcut | Description |
---|---|
i / a |
Insert before/after cursor |
I / A |
Insert start/end of line |
o / O (letter) |
Insert new line below/above |
s / S |
Delete char/line and insert |
C / cc |
Change to end of/current line |
gi |
Insert at last insert point |
Esc * |
* <C-[> |
Motions
Shortcut | Description |
---|---|
h * |
* j * |
<C-u> / <C-d> |
Half-page up/down |
<C-b> / <C-f> |
Page up/down |
#Words
Shortcut | Description |
---|---|
b / w |
Previous/Next word |
ge / e |
Previous/Next end of word |
#Line
Shortcut | Description |
---|---|
0 (zero) / $ |
Start/End of line |
^ |
Start of line (non-blank) |
#Character
Shortcut | Description |
---|---|
Fe / fe |
Move to previous/next e |
To / to |
Move before/after previous/next o |
| / n| |
Go to first/n th column |
#Document
Shortcut | Description |
---|---|
gg / G |
First/Last line |
:n * |
* nG |
} / { |
Next/Previous empty line |
#Window
Shortcut | Description |
---|---|
H / M / L |
Top/Middle/Bottom screen |
zt / zz / zb |
Top/Center/Bottom this line |
Motion Diagrams
â¼/ⶠCursor â½/â· Target
#Left-right motions
ââââââââââââââ |
ââââââââââââââ 0 $ âââââââââââââââ
â âââââââââââ ^ fe âââââââââ â
â â ââââââââ Fo te âââââââââ â
â â ââââââââ To 30| ââââ ââ â
â â ââ âââââ ge w ââââ â ââ â
â â ââ â âââ b e ââ â â ââ â
â â ââ â â âh lâ â â â ââ â
â½ â½ â½â½ â½ â½ â½â¼ â¼â½ â½ â½ â½ â½â½ â½
echo "A cheatsheet from quickref.me"
#Up-down motions
- SCREEN 1 START
âââ¬ââââââââââ· #!/usr/bin/python
â â âââââ·
â â â print("Hello")
â â { } ⶠprint("Vim")
â â â print("!")
â â âââ·
â â âââââ¬ââââ· print("Welcome")
G gg H M L k j ⶠprint("to")
â â âââ· print("quickref.me")
â â print("/vim")
â â
â âââââââ·
â - SCREEN 1 END
ââââââââââââââââ· print("SCREEN 2")
Comments