Vim Tips & Productivity — Master the Modal Editor
Vim's modal editing model is the most efficient way to manipulate text once you internalize its grammar of verbs, modifiers, and text objects. This guide covers the productivity techniques that separate casual Vim users from power users.
What You'll Learn
You'll master Vim motion modifiers and text objects to edit at the speed of thought, record and replay complex macros, use marks and the jump list for rapid navigation, and manage sessions so you can pick up exactly where you left off.
Why Vim Productivity Matters
Every keystroke you save compounds over thousands of edits per day. A Vim user who navigates with f, t, and text objects instead of arrow keys saves seconds per edit — adding up to hours per week. The techniques in this guide are the highest-leverage skills you can learn in any editor.
DodaTech's infrastructure team uses Vim for all server-side editing because it works over SSH with zero latency and no graphical dependencies.
Learning Path
flowchart LR A[Vim Basics] --> B[Vim Tips & Productivity
You are here] B --> C[Vim Advanced] C --> D[Neovim Setup] style B fill:#f90,color:#fff
Motion Modifiers and Counts
Vim motions accept a numeric count that repeats the motion:
" Move 5 lines down
5j
" Delete 3 words
d3w
" Change inside 2 parentheses
ci2(
" Move to the 4th occurrence of 'x' on this line
4fx
" Go up 10 lines and insert
10kO
Combining counts with operators creates powerful compound commands:
" Copy 8 lines downward
y8j
" Delete 6 characters forward
d6l
" Change to the 3rd quote on the line
c3f"
Text Objects
Text objects are Vim's superpower — they define structural regions of text independent of cursor position:
" Inside/around word
ciw " Change inside word
daw " Delete around word (includes trailing space)
" Inside/around quotes
ci" " Change inside double quotes
da' " Delete around single quotes (includes quotes)
" Inside/around brackets
ci( " Change inside parentheses
da[ " Delete around brackets
ci{ " Change inside curly braces
" Inside/around tags
cit " Change inside HTML tag
dat " Delete around HTML tag
" Sentences and paragraphs
cis " Change inside sentence
dap " Delete around paragraph
These work in any mode and with any operator (d, c, y, v):
" Practical examples
ciw " Replace the word under cursor
ci" " Replace string inside quotes
daW " Delete WORD (non-whitespace delimited)
yit " Yank content inside HTML tags
Macros
Macros record a sequence of commands and replay them:
" Record macro 'a': wrap each line in quotes
qa " Start recording into register 'a'
I"<Esc> " Insert " at start of line
A"<Esc> " Append " at end of line
j " Move to next line
q " Stop recording
" Replay macro 'a' 10 times
10"@a]
" Replay the last-used macro
@@
Editing Macros After Recording
" View macro contents
:reg a
" Edit the macro: open the register in the command line
:let "@a" = ''
" Paste the register content (from :reg output) and edit
" Then save back:
:let "@a" = "edited contents here"
Recursive Macros
" Run macro 'b' on every line matching a pattern
qb " Start recording 'b'
:.,/pattern/-1 global command
q " Stop recording
" Execute macro 'b' once — it will chain automatically
"@b"
Marks
Marks let you bookmark locations in files:
" Set marks
ma " Mark current position as 'a'
mA " Mark current position as 'A' (global, works across files)
" Jump to marks
`a " Jump to exact position of mark 'a'
'a " Jump to start of line containing mark 'a'
" List all marks
:marks
" Delete a mark
:delm a
Practical Mark Workflow
" Set mark at function definition
ma
" Navigate elsewhere in the file
/Ctrl+o
" Return to the function
`a
Jump List and Change List
Vim tracks your navigation and edit history:
" Jump list — every time you move by more than one line
Ctrl+o " Go back in jump list
Ctrl+i " Go forward in jump list
" View jump list
:jumps
" Change list — every location where you made an edit
g; " Go to previous change
g, " Go to next change
" View change list
:changes
Use the jump list as a stack — Ctrl+o to pop back to where you came from, even across files.
Quickfix List
The quickfix list collects locations from compilation, search, or linting results:
" Build and populate quickfix
:make
" Search project and populate quickfix
:vimgrep /pattern/ **/*.py
" Or use grep and populate quickfix
:grep -r "function" src/
" Navigate quickfix
:cnext " Next item
:cprev " Previous item
:cfirst " First item
:clast " Last item
" Open quickfix window
:copen
" Close quickfix window
:cclose
Session Management
Sessions save your entire workspace — open files, window layout, marks, registers:
" Save current session
:mksession ~/.vim/sessions/project.vim
" Load a session
:source ~/.vim/sessions/project.vim
" Or start Vim with a session
vim -S ~/.vim/sessions/project.vim
Autosave Sessions on Exit
" Add to .vimrc
autocmd VimLeave * mksession! ~/.vim/sessions/last.vim
Spell Checking
" Enable spell check for English
:set spell spelllang=en_us
" Navigation
]s " Next misspelled word
[s " Previous misspelled word
" Suggestions
z= " Show suggestions for misspelled word
" Mark as correct
zg " Add word to spell file
zw " Mark word as incorrect
zug " Remove word from spell file
Common Productivity Mistakes
1. Not Using Counts
Pressing dddddddddd instead of 10dd. Motions and operators all accept counts. Use them.
2. Arrow Key Navigation in Insert Mode
Arrow keys in insert mode exit to normal mode, move, and re-enter insert mode. Use Ctrl+o in insert mode for a single normal-mode command instead.
3. Repeating Manual Edits Instead of Macros
If you find yourself doing the same 5-keystroke edit on 50 lines, record a macro. It takes 10 seconds and saves 5 minutes.
4. Ignoring the Jump List
Ctrl+o is the fastest way to return to your previous location. Many users scroll back manually instead.
5. Not Using Text Objects
Typing diw (delete inside word) under the cursor is faster than bdw (back, delete word) — and works regardless of cursor position within the word.
6. Overusing Visual Mode
Instead of selecting text then pressing d, use operator+motion directly: dap deletes a paragraph without entering visual mode.
7. Forgetting Session Files
Starting fresh every day wastes time reopening files. Use :mksession and save 30 seconds per session.
Practice Questions
1. What does ci" do in Vim?
Change (delete and enter insert mode) inside the nearest double quotes — deletes everything between the quotes and positions the cursor between them in insert mode.
2. How do you record and replay a macro that operates on 15 lines?
Press q followed by a register name (e.g., a), perform the edits, press q again to stop. Replay with 15@a.
3. What is the difference between the jump list and the change list? The jump list tracks cursor navigation moves (search results, file switches, large cursor movements). The change list tracks every location where you made an edit.
4. How do you navigate the quickfix list after a project-wide search?
Use :cnext and :cprev to move between results. Use :copen to open the quickfix window for an overview.
5. Challenge: You have a CSV file with 200 rows where the first column is a name in "Last, First" format. Use Vim macros to convert every row to "First Last" format without writing a script.
Answer: Record a macro: f, to find the comma, x to delete it, l to move right past the space, dW to delete the first name, P to paste it before the last name, j to move down. Run :@a on the remaining rows. Use a count for the remaining rows.
FAQ
What's Next
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Updated 2026-06-23.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro