2

I am learning to use VIM to write Python code. Frequently, I need to perform replacements that include metacharacters, e.g. replacing all instances of '2**NN' with 'MM'. How can I achieve this?

3

In order to match a literal *, you can escape the * metacharacter with backslashes:

:%s/2\*\*NN/MM

See the user manual for an introduction to Vim's search/replace functionality:

:h usr_27.txt

The reference manual contains more detailed information on Vim's regular expressions:

:h regexp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.