Master Vim: Essential Commands for Faster Coding and Efficient Editing
This guide explains how to harness Vim’s core principles—command‑mode habit, combination and repetition—to dramatically speed up coding, covering navigation shortcuts, repeatable edit techniques, visual‑block tricks, and practical examples that transform everyday editing into a highly efficient workflow.
Command Mode Should Be the Norm
In Vim you must perform actions in command mode. Saving a file requires :w, which means pressing Esc then :w. Frequent use of Esc to switch to command mode becomes a vital reflex; when you are not inserting text, stay in command mode.
HJKL Lets Your Right Hand Rest
The keys H, J, K, L move the cursor left, down, up, and right without moving the right hand to the arrow keys. When you work mainly in command mode, using HJKL reduces hand travel and becomes an automatic reflex.
Make Your Operations Repeatable
Example: transform a line one two three four five six into "one","two","four","five","six". Steps:
Place the cursor at the line start with ^.
Press f (space) to jump to the first space, then c "," to replace the space with a comma and enter insert mode.
Press ; to repeat the last f search, then . to repeat the c "," change. Repeat until all spaces are replaced.
Finally use I and A to add opening and closing quotes.
The key idea is that the f (find) command and the repeat operator ; make the edit fully repeatable.
Efficient Movement
set relativenumber– shows line numbers relative to the cursor, enabling quick +j / +k jumps. w, e, b – word‑wise navigation (with optional counts). I, A – jump to line start/end and enter insert mode. H, M, L – move to top, middle, bottom of the visible window. Ctrl+D, Ctrl+U – page down/up. ^, $, 0 – move to line start, line end, absolute line start. % – jump to the matching bracket. gj, gk – move by screen lines when wrapping occurs. f, F – find a character forward/backward; ; repeats the last f/F search. . – repeat the last change command.
Efficient Modification
r– replace a single character. cw – change a word. caw – change a word including surrounding whitespace. c$, c^ – change to end/start of line. ci", ci(, ci[ – change inside quotes, parentheses, brackets. cit – change inside an XML/HTML tag. yi", ya" – yank (copy) inside or around quotes. yw, yaw, daw, d$ – various delete/yank operations. o, O – open a new line below/above. u, Ctrl+r – undo and redo.
Visual Mode: A Mouse‑Habit with Powerful Uses
Press v, V, or Ctrl+v to enter visual, line‑wise, or block‑wise visual mode. Block visual ( Ctrl+v) lets you select columns. Example: convert a vertical list
one
two
three
fourinto a single quoted CSV line "one, two, three, four" using the sequence Ctrl+v 3j $ A , Esc V 3j J. The relative‑number setting helps determine the count (e.g., 3j).
Conclusion
Vim may not surpass a full IDE in raw features, but its editing speed can outpace mouse‑driven workflows. Mastering these command‑mode habits, repeatable edits, and visual tricks continuously reshapes your editing style, leading to a highly efficient, personalized workflow.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
