RTFM · Tools
vim survival and fluency
Editing on a server means vim eventually meets everyone. Survive the first hour honestly, then learn why its modal model repays the investment for decades.
Guaranteed exit paths
:q! # abandon changes, quit
:wq # save, quit
ZZ # synonym save-quit
Esc # return to normal mode from anywhere
Modal mental model
Normal mode interprets keystrokes as verb+noun commands rather than literal text. Insert mode (i/a/o) enters typing; Esc returns. Compositions become describable intentions rather than mouse marathons.
- Motion nouns: w word, b back-word, 0 line-start, $ line-end, gg doc-top, G doc-bottom.
- Verb prefixes: d delete, y yank, c change, gu lowercase, gU uppercase.
- Combinators compose: dw deletes word, d$ to end-of-line, ciw change inner word.
Practical editing patterns
/pattern<Enter> # search forward
:%s/old/new/gc # whole-file replace with confirmations
:r !date # insert command output
u / Ctrl-r # undo/redo
Indispensable structural moves: visual select rows (V), then :sort; or '>' indent on selection. vim rewards thinking in structures bigger than characters.
Working config for sysadmin use
~/.vimrc:
set nocompatible
set number relativenumber
syntax on
set expandtab shiftwidth=4
set incsearch hlsearch
nnoremap <Space> :nohlsearch<CR>
Prove it works: deliberate edit capability
open a remote config over SSH, perform targeted multi-spot changes, save confidently, exit deliberately; no consultation needed.
Registers, macros and :global
Three facilities turn vim from editor into a light automation engine; all available over SSH on a production box, no plugins.
- Registers: "ayy yanks the current line into register a; "ap pastes it. Uppercase "Ayy APPENDS to a instead of replacing; build a multi-site yank one line at a time. The unnamed register "" always holds the last yank/delete.
- Macros: qa ... q records everything typed into register a; @a replays it; 10@a replays ten times. Record one edit that works on one line, then let the machine repeat it on the rest.
- :global: :g/^#/d deletes every line starting with #; :g/error/normal @a runs your macro on every error line. One command, whole-file scope, zero plugins.
:%s/old/new/gc # confirm-each replace (from the survival kit)
:g/DEBUG/d # remove every DEBUG line
:2,20>/dev/null # no: instead ->
:2,20s/^/ / # indent lines 2-20 by two spaces
:vimdiff a.conf b.conf # or from shell: vim -d a.conf b.conf
vimdiff (or vim -d) splits two files with synced folding of differences; the fastest way to compare a changed config against its backup without leaving the terminal.
Marks, jumps and finding yourself again
- Marks: ma sets mark a at the cursor; `a jumps back exactly; 'a jumps to the line. Uppercase marks (mA) work across files in the same session.
- Jumps: Ctrl-o goes backwards through jump history, Ctrl-i forwards; the undo of navigation.
- In-file search pairs: * searches the word under the cursor; n/N cycle matches; % bounces between matching brackets.
- gf opens the filename under the cursor; handy for hopping between config includes.
These matter most in long sessions on remote machines: set a mark at the section you are editing, wander off to read definitions, Ctrl-o your way home. Muscles learn this in a week; the payoff lasts a career.
Did we miss something?
If this page left something unanswered, found an error, or there is another subject you would like documented, tell us. Saphira’s documentation grows from real problems people need to solve.
Send feedback or request a new section →
Prefer not to do it yourself?
Everything needed to do the work yourself is documented here and remains free; we charge for human time, not for withholding knowledge. Sometimes the missing resource is simply time. The same people who build Saphira can provide paid professional help with implementation, migration, troubleshooting and administration.