Vim Recall繁體中文

Replace in selected lines

:'<,'>s/old/new/g

Example

Normal 0 / 3
old old
old
Cursor on line 1, column 1

Replace matches in the lines touched by a Visual selection.

Before & after
Before
old old
old
Cursor on line 1, column 1
After
new new
old
Cursor on line 1, column 1

ILLUSTRATION. 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.