I want to match a pattern, replace part of the pattern, and use a variable within the pattern as part of the replacement string.
Is this correct?
/s/^((\\s
I don't think anyone really understood the question. Basically, the way I'm doing this is as follows:
"If you want to search for a replacement pattern, pattern a, and replace it with a replacement string, pattern i, only if it starts with a pattern, pattern b, then you need to include pattern b in the replacement string, like this: :/(pattern b)(pattern a)/(pattern b)(i)/g".
It's a little wordy but worth reading.
In the past, I'm sure that someone has thought, "It could save a lot of resources to not actually replace pattern b
with pattern b
. It's redundant to do so." Maybe it happens automatically. I haven't found a built-in method in vi or any other program to do that. I'm sure I could write a script to do it, though.