Vim Recall繁體中文

Confirm replacements throughout a file

:%s/old/new/gc

Example

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

Ask before replacing each old match.

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

ILLUSTRATION. gdefault and edcompatible are off. Three old matches are prepared; answer y, n, then q.

Details & Vim help

Ask before replacing each old match.

With gdefault and edcompatible off, g considers all matches and c requests confirmation. Answer y to replace, n to skip, a for all remaining, q to quit, or l to replace this one and stop.