How do I apply an Ex command only to the exact range of my last change or yank?
When you need to run a command on exactly the text you just changed, yanked, or pasted, Vim's automatic marks are faster and safer than reselecting manually.
category:
command-line
tags:
#command-line
#marks
#indentation
#ex-commands
#normal-mode
How do I prepend text to every selected line even with uneven indentation?
Visual Block insert (I.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#normal-mode
#editing
How do I replay a macro many times without cluttering the jumplist?
Running a macro hundreds of times is efficient, but it can flood your jumplist and make normal navigation painful afterward.
category:
macros
tags:
#macros
#automation
#normal-mode
#navigation
How do I replay macro q from command-line mode without changing @/?
:keeppatterns normal! @q<CR>
When you replay macros from Ex commands, Vim can overwrite @/ (the last search pattern) depending on what the macro does.
category:
macros
tags:
#macros
#registers
#search
#normal-mode
#automation
How do I run a recorded macro on every file in my argument list at once?
The :argdo command applies any Ex command to every file in the argument list.
category:
macros
tags:
#macros
#ex-commands
#argdo
#normal-mode
#editing
How do I execute a macro while ignoring custom mappings that could change behavior?
Recorded macros can become fragile when your config defines mappings that shadow built-in keys.
category:
macros
tags:
#macros
#normal-mode
#mappings
#command-line
How do I apply a macro to every line in a visual selection?
The :'normal @q command runs macro q on every line of the visual selection.
category:
visual-mode
tags:
#visual-mode
#macros
#ex-commands
How do I indent the current line without changing local marks in Vim?
When you run editing commands from the command line, Vim usually updates special marks like '[ and '] to the changed text.
category:
editing
tags:
#editing
#ex-commands
#marks
#normal-mode
How do I apply a recorded macro to a range of lines without re-recording it in Vim?
The :[range]normal @a command runs a recorded macro against every line in a given range.
category:
macros
tags:
#macros
#registers
#ex-commands
#normal-mode
#advanced
How do I apply a macro only to files that appear in the current location list?
:lfdo normal! @q | update
When you already have a curated location list, :lfdo lets you apply a change only to those files instead of touching your whole project.
category:
macros
tags:
#macros
#location-list
#refactoring
#command-line
#normal-mode
How do I execute a macro from bottom to top over a selected range?
Running a macro over a range usually goes top to bottom, but that can break when the macro inserts or deletes lines.
category:
macros
tags:
#macros
#ex-commands
#visual-mode
#normal-mode
#refactoring
How do I jump to a literal search target without adding jump-list noise?
:keepjumps normal! /\Vtarget\<CR>
Repeated navigational searches can pollute the jump list, especially when you are doing targeted inspections before returning to your main edit location.
category:
navigation
tags:
#navigation
#search
#jumplist
#normal-mode
#workflow
How do I run a macro a dynamically computed number of times or interleave it with other commands?
:for i in range(1,10) | execute "normal @q" | endfor
Using a Vimscript :for loop with execute "normal @q" lets you run a macro with a dynamically computed iteration count and interleave other Ex commands between i
category:
macros
tags:
#macros
#ex-commands
#normal-mode
How do I run a macro on every line in a specific line number range?
The :normal command lets you execute Normal mode keystrokes over a range of lines.
category:
macros
tags:
#macros
#normal
#range
#ex-commands
How do I apply a macro to every line in a specific range without running it manually each time?
The :[range]normal @q command replays the macro in register q on every line within a given range.
category:
macros
tags:
#macros
#normal-mode
#ex-commands
#ranges
How do I jump to the top of a file without creating a new jumplist entry?
Sometimes you need to make a quick structural move (for example, jump to top, inspect context, then return) without polluting jump navigation history.
category:
navigation
tags:
#navigation
#jumplist
#command-line
#workflow
How do I apply a macro across multiple files at once?
:argdo normal @q | update
The :argdo command runs a command in every file in the argument list.
category:
macros
tags:
#macros
#batch-editing
#multi-file
#ex-commands
#workflow
How do I run a macro on every line in the file silently, ignoring errors on lines where the macro fails?
Combining :silent!, the % range, and :normal @q gives you a powerful pattern for applying a macro across an entire file while gracefully skipping lines that don
category:
macros
tags:
#macros
#editing
#ex-commands
#normal-mode
How do I execute a recorded macro once in each currently open window?
When you split a file into multiple windows or keep several related buffers visible, repeating the same small cleanup in each one can be tedious.
category:
macros
tags:
#macros
#windows
#normal-mode
#ex-commands
#automation
How do I dynamically build and run Ex commands from strings in Vim?
:execute 'normal! ' . count . 'j'
The :execute command evaluates a string as an Ex command, enabling dynamic command construction.
category:
command-line
tags:
#command-line
#execute
#scripting
#dynamic