There is a search and replace operation that I am trying to do using feedback and regular expressions in vim. Interestingly, it will only recognize the pattern if I do a clean search, but if I do a search and replace it, it will get error E486: the pattern was not found.
I have a bunch of form function calls:
function( Nullable< double >(1.1), map[FOO] );
Where FOO is some other variable name on each line. I want to turn it into
function( othermap[ FOO ], map[FOO] );
If i try
:%s/Null.*\(map[\)\(.*\)\]/othermap[ \2 \], \1\2\]/g
He gives me a "Not Found Template Error". Even
:%s/Null.*\(map[\)\(.*\)\]//g
will not work because it just does not recognize the pattern. But if I try the following command with the same search regex:
/Null.*\(map[\)\(.*\)\]
It is highlighted correctly. After that, I can do% s // othermap [\ 2], \ 1 \ 2] to do my replacement. Therefore, I was able to make my replacement in the end, but I canβt let my life understand why the pattern will be recognized in one case and not in another.
bhh1988
source share