How do I replay a macro many times without cluttering the jumplist?
Answer
:keepjumps normal! 500@q
Explanation
Running a macro hundreds of times is efficient, but it can flood your jumplist and make normal navigation painful afterward. Wrapping macro replay in :keepjumps keeps your history clean while still performing a large batch operation.
How it works
:keepjumps normal! 500@q
:keepjumpsprevents jump-list updates from the command it prefixesnormal!executes Normal-mode keys literally (ignores user mappings)500@qreplays macro registerqup to 500 times
This is especially useful for structured edits where each macro run moves to the next target and may fail naturally at the end. You still get fast automation, but you avoid a polluted jumplist that would otherwise break <C-o> and <C-i> navigation flow.
Example
Suppose macro q edits one matching line and moves to the next candidate. Instead of manually pressing @q repeatedly, run:
:keepjumps normal! 500@q
The macro executes in bulk, and your jump history remains focused on meaningful navigation points.
Tips
- Pick a count safely above expected matches (for example
200or1000) - Keep
normal!instead ofnormalfor deterministic behavior - Pair with
:set lazyredrawtemporarily when replaying very large macro batches