D

Vim

Vim navigation, editing and search commands for fast work on a remote server.

Updated 2026-09-03

On this page

The one editor guaranteed to be on every server you SSH into. You don't need to know all of Vim — you need enough to edit a config file and get out safely.

Modes

i

Enters insert mode before the cursor.

Esc

Returns to normal mode from insert, visual, or command mode.

v

Enters visual mode, for selecting text character by character.

:

Enters command mode, for ex commands like :w, :q, :s.

Saving & Quitting

:w

Writes (saves) the file.

:q

Quits — fails if there are unsaved changes.

:wq

Writes then quits.

:q!
destructive

Quits and discards unsaved changes. There is no undo once you've quit — confirm you actually want to lose the edits first.

ZZ

Shorthand for :wq in normal mode.

h j k l

Left, down, up, right — the original arrow keys, still faster than reaching for real ones.

w

Jumps to the start of the next word.

b

Jumps to the start of the previous word.

0

Jumps to the start of the current line.

$

Jumps to the end of the current line.

gg

Jumps to the first line of the file.

G

Jumps to the last line of the file.

:42

Jumps to line 42.

Editing

dd

Deletes (cuts) the current line.

yy

Yanks (copies) the current line.

p

Pastes after the cursor/current line.

u

Undoes the last change.

Ctrl-r

Redoes a change that was just undone.

x

Deletes the character under the cursor.

dw

Deletes from the cursor to the start of the next word.

cc

Deletes the current line and enters insert mode — change the whole line in one step.

Search & Replace

/pattern

Searches forward for a pattern. Press n for the next match, N for the previous.

?pattern

Searches backward for a pattern.

:%s/old/new/g

Replaces every occurrence of old with new on every line in the file.

:%s/old/new/gc

Same, but prompts for confirmation before each replacement — safer for a change you're not fully sure of.

Visual Mode

v

Character-wise visual selection.

V

Line-wise visual selection.

Ctrl-v

Block-wise visual selection, for editing a rectangular column across multiple lines.

>

Indents the selected lines (in visual mode).

Buffers & Files

:e filename

Opens another file in the current window.

:bnext

Switches to the next open buffer.

:ls

Lists all open buffers.

Ctrl-w s

Splits the window horizontally.

Ctrl-w v

Splits the window vertically.

Stuck in Vim?

Press Esc a few times to guarantee you're in normal mode, then type :q! and Enter to quit without saving — the fastest way out if you opened it by accident.

Official documentation

Related