Editor Cheat-Sheets (for Mac Keyboards)
I really enjoy using the console. Not only on my Mac, but also frequently on remote systems. And here I constantly switch between the editors vi
and nano
.
Unfortunately, I am also a very forgetful person and keep forgetting the same keyboard shortcuts or mixing them up. So what could be more obvious than creating little cheat sheets of the most frequently used shortcuts as a reminder?
Here we go...
Cheat Sheet: nano
Line start
Ctrl+A
Line end
Ctrl+E
Document start
Option+\\
Document end
Option+/
Page up
Ctrl+Y
Page down
Ctrl+V
Go to line/column
Ctrl+_
Search forward
Ctrl+W
Next match
Option+W
Replace
Ctrl+\\
Search options (prompt)
Option+C (Case) • Option+R (Regex)
Cut (line)
Ctrl+K
Uncut (paste)
Ctrl+U
Copy
Option+6
Mark text
Ctrl+^
Undo / Redo
Option+U / Option+E
Write out (save)
Ctrl+O
Read file (insert)
Ctrl+R
Exit
Ctrl+X
Cancel / abort input
Ctrl+C
Help
Ctrl+G
Justify (align)
Ctrl+J
Spell check
Ctrl+T
Execute command
Ctrl+R , Ctrl+X
You can download a PDF version of the nano
cheat sheet here.
Cheat Sheet: vi
Line up / down
k / j
Word forward / backward
w / b
Line start / end
0 / $
File start / end
gg / G
Page up / down
Ctrl+b / Ctrl+f
Insert (line start)
i • I
Insert (line end)
a • A
New line (above)
O
New line (below)
o
Visual
v (char) • V (line) • Ctrl+v (block)
Back to normal mode
Esc
Delete
x (char) • dd (line) • d + motion
Yank (copy)
yy (line) • y + motion
Paste
p (after) • P (before)
Change
c + motion • cc (line)
Repeat / Undo / Redo
. / u • Ctrl+r
Search forward / backward
/ pattern • ? pattern
Next / previous match
n / N
Word under cursor
* / #
Replace in file
:%s/old/new/g • confirm: :%s/old/new/gc
Save / Quit
:w • :q • :wq • :q!
Open / reload file
:e file • :e!
Switch buffer
:bn / :bp • :b nr|name
Split / vsplit
:split • :vsplit
Switch between splits
Ctrl+w h/j/k/l
Close split / only this
:q • :only
You can download a PDF version of the vi
cheat sheet here.