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.


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

| improve this answer | |
  • 1
    The escape is in the help tag, too :help /\+ – Rich Jan 11 at 10:13
  • I didn’t know about :help pattern. Thx – Oswaldo Nickel Jan 14 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.

| improve this answer | |
  • I was always wondering about that. Now i know. Thx – Oswaldo Nickel Jan 14 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. – Enrico Maria De Angelis Jan 14 at 7:03

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.