All posts

Vim without panic: a remote-server survival guide

The small set of Vim commands I need when SSH drops me into a server and a configuration file has to change safely.

A calm navigation path through a remote terminal editing session

Archive note: this guide was recovered from my former WordPress notebook. The original date is preserved; commands and links may be updated as I verify them.

Vim becomes intimidating when it appears unexpectedly on a remote server. The useful mental model is smaller than the editor: Normal mode is for navigation and commands, Insert mode is for typing, and Command-line mode is for saving or leaving.

Cheat sheet showing Vim navigation, editing, undo, save and quit commands

The three modes that matter

  • Normal mode: press Esc. Move, delete, copy, paste or start another command from here.
  • Insert mode: press i to type before the cursor, a to type after it, or o to open a new line.
  • Command-line mode: from Normal mode, press : and enter commands such as w, q or wq.

Navigation and editing

h  left
j  down
k  up
l  right
w  next word
b  previous word
0  start of line
$  end of line
x   delete character
dw  delete to next word
dd  delete line
u   undo
Ctrl-r  redo
yy  copy line
p   paste

Saving and escaping

:w    save
:q    quit when nothing changed
:wq   save and quit
:q!   quit and discard changes

If the editor seems frozen, press Esc first. That returns to a known state. Then use :wq to keep the change or :q! to abandon it.

A safe configuration-editing loop

  1. Copy the file before editing it, especially when it controls SSH, a proxy or a production service.
  2. Make the smallest possible change and save it.
  3. Run the service's configuration test before reloading it.
  4. Reload instead of restarting when the service supports it, then inspect logs and the public health check.

The editor is only the first half of the job. A production change is complete when the service still responds and monitoring confirms the expected behaviour. That is the same operating principle behind Ecreativ Monitoring: make failure visible before a visitor reports it.