Vim Recall繁體中文

Repeat the last substitution without its flags

:&

Example

Normal 0 / 2
new old
old old
Cursor on line 2, column 1

Repeat the last substitution without its flags.

Vim registers

/ Last search register
Characterwiseold
· space ⇥ tab ↵ line break
Before & after
Before
new old
old old
Cursor on line 2, column 1

Vim registers

/ Last search register
Characterwiseold
· space ⇥ tab ↵ line break
After
new old
new old
Cursor on line 2, column 1

Vim registers

/ Last search register
Characterwiseold
· space ⇥ tab ↵ line break

Start in Normal mode. A prior :s/old/new/ replaced the first old on line 1, establishing old as the previous pattern and new as the previous replacement. The cursor then moved to line 2; this command reuses that prepared replacement state.

Details & Vim help

Example replayed in Vim

Repeat the previous replacement on the current line using the previous substitution pattern. The bare form drops the previous flags. Add & as the first flag to keep them.