Getting Started
Motion Diagrams
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("cheatsheets.zip")
│ │ print("/vim")
│ │
│ └─────▷
│ - SCREEN 1 END
└──────────────▷ print("SCREEN 2")
Motions
| Shortcut |
Description |
h | j | k | l |
Arrow keys |
<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/nth column |
Document
| Shortcut |
Description |
gg / G |
First/Last line |
:n | nG |
Go to line n |
} / { |
Next/Previous empty line |
Window
| Shortcut |
Description |
H / M / L |
Top/Middle/Bottom screen |
zt / zz / zb |
Top/Center/Bottom this line |
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-[> |
Exit insert mode |
Saving and Exiting
| Shortcut |
Description |
:w |
Save |
:q |
Close file |
:wq | :x | ZZ |
Save and quit |
:wqa |
Save and quit all files |
:q! | ZQ |
Force quit |
: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 |
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 |
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 |
Paste from system clipboard |
"*y | "+y |
Paste to system clipboard |
In visual mode
| Shortcut |
Description |
d | x |
Delete selection (Cut) |
s |
Replace selection |
y |
Yank selection (Copy) |
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 |
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 |
Macros
| - |
- |
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