3

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?

Stefano
  • 33
  • 3

1 Answers1

4

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
Rich
  • 31,891
  • 3
  • 72
  • 139