Replace with Confirmation using Vim
This page answers questions like these:
- How to do text replace with confirmation using vim/vi?
- How to do a global replace with confirmation using vim/vi?
- How to do a global replace with confirmation at each one using vim/vi?
Related Links:
Find Surrounding Code Block in Vim
Fold/Collapse/Hide Code Blocks in Vim
Expand/Show/Open Collapsed/Hidden/Folded Text in Vim
Write Lines to Another File in Vim/Vi
E432: Tags file not sorted: tags | E257: cstag: tag not found | E426: tag not found:
Replace with Confirmation using Vim:
:s/PATTERN1/PATTERN2/gc
- On the current line, substitute every PATTERN1 with PATTERN2, stopping at each one and asking for confirmation.
- : = Perform an ed command.
- s/PATTERN1/PATTERN2/ = Substitute PATTERN1 with PATTERN2.
- g = Every match per line. (No g = Only the first match per line.)
- c = Ask for confirmation. (No c = Do not ask for confirmation.)
Multi-line Replace with Confirmation using Vim:
:10,30s/PATTERN1/PATTERN2/gc
- From line 10 to line 30 (inclusive) substitute every PATTERN1 with PATTERN2, stopping at each one and asking for confirmation.
- : = Perform an ed command.
- 10,30 = From line 10 to line 30 (inclusive).
- s/PATTERN1/PATTERN2/ = Substitute PATTERN1 with PATTERN2.
- g = Every match per line. (No g = Only the first match per line.)
- c = Ask for confirmation. (No c = Do not ask for confirmation.)
Global Replace with Confirmation using Vim:
:%s/PATTERN1/PATTERN2/gc
- Globally substitute every PATTERN1 with PATTERN2, stopping at each one and asking for confirmation.
- : = Perform an ed command.
- % = On every line.
- s/PATTERN1/PATTERN2/ = Substitute PATTERN1 with PATTERN2.
- g = Every match per line. (No g = Only the first match per line.)
- c = Ask for confirmation. (No c = Do not ask for confirmation.)
Related Links:
Find Surrounding Code Block in Vim
Fold/Collapse/Hide Code Blocks in Vim
Expand/Show/Open Collapsed/Hidden/Folded Text in Vim
Write Lines to Another File in Vim/Vi
E432: Tags file not sorted: tags | E257: cstag: tag not found | E426: tag not found:
Home > Vim > Replace with Confirmation using Vim
Tags: vim replace with confirmation, confirmation, confirm, replace with confirm, global replace, yes/no, vim
Copyright © HelpDoco.com
vim-replace-with-confirmation.txt
Vim/vim-replace-with-confirmation-using-vim.htm
3