Essential Vim Commands and Options: A Complete Cheat Sheet
This article honors Bram Moolenaar while providing a comprehensive Vim cheat sheet that covers essential editing commands, cursor navigation, deletion, searching, substitution, copy‑paste operations, and key editor options, offering developers a practical reference for mastering the powerful open‑source text editor.
Tribute to Bram Moolenaar
Vim, short for “Vi IMproved,” is a powerful, open‑source, modal text editor created by Bram Moolenaar in 1991. The article begins with a brief biography of Moolenaar, highlighting his dedication to the project, his Dutch background, and his commitment to community‑driven development. It notes his charitable initiative that encourages users to donate to ICCF Holland, a charity supporting children in Uganda.
Common Editing Commands
These commands are executed in command mode: i, a, r – insert characters before, after, or replace 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 the character under the cursor, delete to end of line, or delete the entire line.
Cursor Movement
h, j, k, l – move left, down, up, right. Ctrl+f, Ctrl+b – page down/up. nG – jump to line n. w, b, e – move forward/backward by words. 0 and $ – move to start or end of the current line. H, M, L – move to top, middle, or bottom of the screen.
Deletion Commands
ndwor ndW – delete n words starting at the cursor. do – delete to the beginning of the line. d$ – delete to the end of the line. ndd – delete n consecutive lines. x / X – delete a character after or before the cursor. Ctrl+u – clear the current input in insert mode. n1,n2d – delete lines from n1 to n2. %d or 1,$d – delete the entire file.
Search Commands
/pattern– search forward for pattern. ?pattern – search backward. /\/pattern – search for a literal slash. n – repeat the last search in the same direction. N – repeat the last search in the opposite direction.
Substitution (Replace) Commands
s/old/new/– replace the first occurrence of old with new on the current line. s/old/new/g – replace all occurrences on the current line. n,$s/old/new/ – replace from line n to the end of the file (first occurrence per line). n,$s/old/new/g – replace all occurrences from line n to the end. %s/old/new/g – replace everywhere in the file. s#old#new# – use an alternative delimiter to avoid escaping slashes.
Copy & Paste (Yank & Put)
yy– yank (copy) the current line. nyy – yank n lines starting from the current line.
Press v then move the cursor to select a region, then y to yank. dd – cut (delete) the current line. p – paste after the cursor; P – paste before. n1,n2co n3 – copy lines n1 ‑ n2 to after line n3. n1,n2m n3 – move lines n1 ‑ n2 to after line n3.
Editor Options
set number– show line numbers; set number! – hide them. set all – list all option values. 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 search at file boundaries. set mesg – allow messages from other users.
Saving and Exiting
:wq– write (save) and quit. :q! – quit without saving. :w – write changes. U – undo last change. Ctrl+r – redo undone changes.
The article concludes by reflecting on Moolenaar’s lasting impact on the open‑source community and encourages developers to continue using Vim as a powerful editing tool.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
