Is it possible to step through the results of a search and replace to ensure that no unwanted modifications were made to your code in a boldly-executed, entire-file search and replace?
Vim throws up the status message:
"*X* substitutions on *Y* lines"
and I'm curious if there's a key or command to step through each of those substitutions and do a quick check to make sure you haven't shot yourself in the foot with an unexpected string match. I am new to Vim.
From http://vim.wikia.com/wiki/Search_and_replace,
:%s/foo/bar/gc
Change each 'foo' to 'bar', but ask for confirmation first.
This is how you should have found that info yourself, without Google, the Vim wiki or SO:
Look for help on the :substitute
command:
:help :s
Read the paragraph and notice the part where it talks about optional [flags]
:
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
[...
skipped lines
...]
See |:s_flags| for [flags].
Hit <C-]>
on the highlighted :s_flags
.
Hooooo…
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With