How do I apply my last normal-mode change to every line in a visual selection?
Answer
:'<,'>normal! .
Explanation
When you already made one correct edit, replaying it is usually safer than retyping it by hand. :'<,'>normal! . applies Vim's repeat-change command (.) to every line in the last visual range, which is extremely useful for structured bulk edits where each line needs the same transformation. This pattern is faster than recording a macro for one-off range edits and keeps your workflow focused.
How it works
'<,'>is the range of the most recent visual selection:normal!executes normal-mode keystrokes for each line in that range.is the built-in repeat command for your last change
The important detail is normal! (with bang), which bypasses custom mappings. That makes batch edits more predictable, especially in heavily customized configs.
Example
Suppose you changed one line from foo=1 to foo: 1 using a normal-mode edit. Now you want the same conversion on selected lines:
foo=1
bar=2
baz=3
Select the target lines in visual-line mode and run:
:'<,'>normal! .
Result:
foo: 1
bar: 2
baz: 3
Tips
- Make your first edit carefully; every line reuses that exact change
- If the edit depends on cursor position, place the cursor consistently on each line before running
- For cross-file batches, combine this with quickfix/location lists and run the same idea via
:cdoor:ldo