Skip to content

Text Editors (Terminal) — Quick Reference

Section titled “Text Editors (Terminal) — Quick Reference”

You’ll encounter it on remote servers whether you like it or not. Knowing enough to edit and escape is survival-level knowledge.

ModeHow to enterPurpose
NormalEscNavigation, commands (default)
Inserti, a, oType text
Visualv, V, Ctrl+VSelect text
Command:Save, quit, search, replace
i insert before cursor
a insert after cursor
o insert new line below
O insert new line above
Esc return to Normal mode
:w save
:q quit
:wq save and quit
:q! quit without saving (force)
:wq! force save and quit
ZZ save and quit (shortcut for :wq)
h j k l left, down, up, right
w jump to next word
b jump to previous word
0 start of line
$ end of line
gg go to first line
G go to last line
:42 go to line 42
Ctrl+D page down
Ctrl+U page up
x delete character under cursor
dd delete (cut) current line
yy yank (copy) current line
p paste after cursor
P paste before cursor
u undo
Ctrl+R redo
. repeat last action
dw delete word
d$ delete to end of line
cw change word (delete + insert)
/pattern search forward
?pattern search backward
n next match
N previous match
:%s/old/new/g replace all in file
:%s/old/new/gc replace all, confirm each
:5,10s/old/new replace in lines 5–10
v character-wise select
V line-wise select
Ctrl+V block/column select
After selecting:
y copy
d delete/cut
> indent
< unindent
:e file.txt open file
:vsplit file.txt vertical split
:split file.txt horizontal split
Ctrl+W + arrow move between splits
:tabnew file.txt open in new tab
gt / gT next / previous tab

Simpler than vim, controls shown at the bottom of the screen.

Terminal window
nano file.txt
ShortcutAction
Ctrl+OSave (Write Out)
Ctrl+XExit
Ctrl+KCut line
Ctrl+UPaste line
Ctrl+WSearch
Ctrl+\Search and replace
Ctrl+GHelp
Alt+UUndo

  • Memorize :wq and :q! first — everything else is secondary.
  • vimtutor (run in terminal) is an interactive 30-minute lesson built into vim itself.
  • Use nano when you just need to make a quick edit and don’t want to think about modes.
  • On most servers, if vim isn’t available, vi (its predecessor) almost certainly is — the core commands are the same.

← Linux