Editing config files, scripts, and sudoedit/crontab -e sessions all eventually come down to a terminal text editor. Which one is actually available differs by system - a minimal server install may have vi (or vim) and nothing else, which is the main reason it's worth knowing even if nano is the daily preference.

nano: immediate and discoverable

nano file.txt

Opens directly into an editable buffer - no mode to learn, and every available command is listed on screen (^ means Ctrl):

^G Get Help  ^O Write Out  ^W Where Is  ^K Cut Text   ^J Justify
^X Exit      ^R Read File  ^\ Replace   ^U Paste Text ^T To Spell
Keys Action
Ctrl+O Save (nano calls it "Write Out")
Ctrl+X Exit (prompts to save if there are unsaved changes)
Ctrl+K / Ctrl+U Cut / paste a line
Ctrl+W Search
Ctrl+\ Search and replace

There's essentially nothing else to learn - this is the whole tool, which is exactly why it's the friendlier default on distros that ship one at all (Debian/Ubuntu; RHEL/Fedora minimal installs often don't).

vim: modal, and everywhere

vim's one genuinely unfamiliar idea is modes - the same keys mean different things depending which mode you're in, which is what makes it confusing before it clicks and fast afterward.

vim file.txt
Mode What it's for How to get there
Normal Navigation and commands (the mode vim opens in) Esc from anywhere
Insert Actually typing text i (insert before cursor), a (after), o (new line below)
Command Save, quit, search/replace, run : commands : from Normal mode

The almost-universal joke about not being able to exit vim comes from not knowing this: pressing i and typing puts you in Insert mode, where :wq is just three more characters of text, not a command. Esc first, then :wq.

Essential vim commands

i          enter Insert mode
Esc        back to Normal mode
:w         save
:q         quit (fails if there are unsaved changes)
:wq        save and quit
:q!        quit WITHOUT saving - discard changes
dd         delete (cut) the current line
yy         yank (copy) the current line
p          paste after the cursor
u          undo
Ctrl+R     redo
/pattern   search forward for pattern
n          jump to the next match

Everything in Normal mode composes: 3dd deletes 3 lines, dw deletes to the end of the current word, d$ deletes to the end of the line - learning to combine a count, an action, and a motion is most of what "getting fast at vim" actually means.

Why vim specifically, not just "a text editor"

  • Installed by default (as vi, functionally equivalent for basics) on nearly every Unix-like system, including minimal containers and rescue environments where nothing else is available
  • sudoedit, crontab -e, and git commit (with no -m) all launch whatever $EDITOR is set to - frequently vim by default on a fresh install
  • Once the modal model is comfortable, editing without ever reaching for a mouse or arrow keys is genuinely fast

Changing the default editor

echo 'export EDITOR=nano' >> ~/.bashrc   # see Environment Variables
sudo update-alternatives --config editor  # Debian/Ubuntu: change the system-wide default

See Environment Variables for how $EDITOR gets picked up by other programs generally.

A middle ground: micro

For a terminal editor with conventional (Ctrl+S save, Ctrl+C copy, arrow-key navigation) bindings and no modal learning curve, micro is worth knowing about - not installed by default anywhere, but a reasonable answer to "I want vim's terminal-only convenience without vim's learning curve."