Fundamentals 7 min read

Essential Vim Commands Cheat Sheet: Editing, Navigation, Search & Replace

This guide provides a concise reference of the most frequently used Vim commands for editing, cursor movement, deletion, searching, replacing, copying, pasting, and configuring options, helping both beginners and experienced users work more efficiently in the editor.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Essential Vim Commands Cheat Sheet: Editing, Navigation, Search & Replace

Common Editing Commands

i

, a, r: insert, append, or replace characters at the cursor. O, o: open a new empty line above or below the current line. cw, dw: change or delete the word under the cursor. x, d$, dd: delete a character, delete to end of line, or delete the whole line.

Cursor Movement

h

, j, k, l: move left, down, up, right. Ctrl+f, Ctrl+b: page down, page up. nG: jump to line number n. w, b: move forward or backward by a word. 0 and $: move to the beginning or end of the current line. H, M, L: move to the top, middle, or bottom of the screen.

Deletion

ndw

or ndW: delete n words starting at the cursor. do: delete to the beginning of the line. d$: delete to the end of the line.

n
dd

: delete n consecutive lines. x / X: delete the character after / before the cursor. %d or 1,$d: delete the entire file.

Search

/pattern

: search forward for pattern. ?pattern: search backward for pattern. n: repeat the last search in the same direction. N: repeat the last search in the opposite direction.

Replace

s/vivian/sky/

: replace the first occurrence of vivian on the current line with sky. s/vivian/sky/g: replace all occurrences on the current line. n,$s/vivian/sky/: replace the first occurrence from line n to the end of file. %s/vivian/sky/g: replace every occurrence in the whole file. s#vivian#sky#: use # as delimiter to avoid escaping slashes.

Copy & Paste

yy

: yank (copy) the current line. nyy: yank n lines starting from the current line.

Press v then move with arrow keys, then y to copy a visual selection. dd: cut (delete) the current line. p: paste below the cursor; P: paste above. n1,n2co n3: copy lines n1n2 to after line n3. n1,n2m n3: move lines n1n2 to after line n3.

Editor Options

set number

: show line numbers; set nonumber (or add !) to hide them. set all: list all option settings. set ignorecase: ignore case in searches. set list: display tabs and end‑of‑line markers. set warn: warn when switching files with unsaved changes. set nowrapscan: stop searching when the end of file is reached. set mesg: allow messages from other users via write.

Saving & Exiting

:wq

: write (save) and quit. :q!: quit without saving. :w: write changes. U: undo all recent changes on the current line. Ctrl+r: redo undone changes.

text editorVimnavigationcommandsCheat Sheetediting
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.