I know it should be easy, but somehow I don’t get it right.

I've got a text with artist_id, album_id,... and want to replace them with just id.

How do I do that?

I tried :%s/[a-z]+_id/id/gc, but it did not work.

2 Answers 2


If you read :help pattern, you’ll see you need \+. Vim’s patterns are not quite like PCRE or POSIX B/ERE

  • 1
    The escape is in the help tag, too :help /\+
    – Rich
    Commented Jan 11, 2020 at 10:13
  • I didn’t know about :help pattern. Thx Commented Jan 14, 2020 at 2:40

In addition to other answers, look in the docs for \v which, at the beginning of the search string, makes it behave as "very magic", which means that + will work the way you want, while \+ will refer to the literal plus sign.

  • I was always wondering about that. Now i know. Thx Commented Jan 14, 2020 at 2:43
  • @OswaldoNickel :help is your friend, always. You can accept this (or the other) answer, however, as a more effective "thank you" that encourages us to answer better and better everytime.
    – Enlico
    Commented Jan 14, 2020 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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