Replace in selected lines
Example
Normal 0 / 3Visual line 1 / 3Command-line 2 / 3Normal 3 / 3old old
oldCursor on line 1, column 1old old
oldCursor on line 1, column 1 · Line selectionold old
oldCursor on line 1, column 1new new
oldCursor on line 1, column 1Replace matches in the lines touched by a Visual selection.
Reselect only the first line.
The Visual marks supply the whole-line range.
Command line
- Input
:'<,'>
Replace both matches on the selected first line.
Before & after
old old
oldCursor on line 1, column 1new new
oldCursor on line 1, column 1ILLUSTRATION. The first line is prepared as the previous Visual line selection. gdefault and edcompatible are off; the range applies to whole touched lines.
Details & Vim help
Replace matches in the lines touched by a Visual selection.
The marks form a line range: substitution affects whole selected lines, even for a characterwise or blockwise selection. The zero-width atom \%V checks only its position; a pattern containing it can still extend outside the Visual area. To confine an entire match, use the start and end checks demonstrated in :help /\%V. Assumes gdefault and edcompatible are off.