I have text like this
template
template
template_results
template
And I need to replace it to this
template_form
template_form
template_results
template_form
How can I replace every match of template that is not followed by _ character in Vi?
I tried it like this
:%s/template[^_]/template_form - Pattern not found
:%s/template\[^_]/template_form - Pattern not found
:%s/template[_]/template_form - This works, but the pattern is opposite of what I need
Thank you 🙂
Use negative lookahead:
This means match any “template” not followed (
\@!) by any “_”See:
:help /zero-width