Every time before I replace pattern1 with pattern2, I usually use /pattern1 to confirm the regex is the right one. When doing the actual substitution, however, I have to use :%s/pattern1/pattern2/g(Suppose I need to do the global replacement). This is annoying and may fail due to typos.
So is there a convenient way to substitute the matched pattern1?
// is last search
:%s//replacement/gwill do what you want.however you could also think about
%s/pattern1/pattern2/gcor%s/p1/p2/gn