I'm reworking some Fortran code. I need to remove the pattern (*,*) using vim's search and replace function. The following does not work


the last one only removes the contents between the parentheses and not the parentheses themselves

  • Did this answer work. If so the tick the ✓. Commented Dec 29, 2017 at 16:08

1 Answer 1


You will have to escape the * as \*. The * is special in regular expressions and means match the previous thing zero or more times.

The substitution in Vim would be


If you unset the magic option in Vim, with

:set nomagic

then only the ^ ("start of line") and $ ("end of line") characters have special meaning in regular expressions.

This means that the substitution


would do what you'd like it to do.

Most people do want to have the magic option set though (and it is set by default in Vim).

  • Small addition: If you want to unset magic only for one expression, you can just add a \v, \V, \M inside your expression :)
    – Bog
    Commented Dec 4, 2023 at 8:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .