Terminal text editors — a survival guide for vim and nano
Editing a config file over SSH means editing it in the terminal, whether you're ready or not. This is the minimum you need to open a file, change one line, and get back out without panicking.
Beginner
2 min read
Why this comes up whether you plan for it or not
Editing a file on a remote server (the SSH lesson) almost always means
editing it with a terminal-based editor, since there's no GUI to open a
familiar editor with. nano and vim are the two you'll run into
constantly — one is meant to be immediately usable, the other is
famously not, and knowing which is which before you're stuck matters.
nano: what you actually want most of the time
nano behaves close to a normal text editor — arrow keys move the cursor,
typing inserts text, and the commands you need are listed at the bottom of
the screen the whole time:
$ nano config.txt
^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^X Exit
^ means Ctrl, so ^X is Ctrl+X to exit, ^O (Ctrl+O) to save ("write
out"). For a quick edit — changing one line in a config file, adding an
environment variable — nano is almost always the right choice, exactly
because it doesn't require memorizing anything before you can use it.
vim: why it looks broken the first time
Opening vim for the first time and typing normally produces chaos —
letters trigger commands instead of appearing on screen. That's not a bug:
vim has modes, and it opens in "normal" mode, where keys are commands,
not text input.
The absolute minimum survival sequence:
$ vim config.txt
Press i to enter insert mode — now typing works like a normal editor.
Make your edit.
Press Esc to return to normal mode.
Type :wq and press Enter to save and quit (:w writes/saves, :q
quits — :wq does both).
If you want to abandon your changes instead: Esc, then :q!
and Enter (the ! forces quitting without saving).
That's genuinely enough to survive being dropped into vim unexpectedly —
everything past this (search, multiple windows, macros) is optional depth
for later, not a prerequisite for making one small edit.
Why this matters day to day
Every engineer eventually SSHs into a server, needs to change one line of a
config file, and either already knows this or loses ten frustrated minutes
figuring out how to exit vim for the first time — a common enough moment
that it's become something of an industry joke. Knowing the five-step
sequence above in advance is the difference between a 30-second edit and a
genuinely stressful production incident made worse by fighting the editor
instead of fixing the actual problem.