Sabrina
Sabrina

Reputation: 1466

Understanding behavior of backreferencing in vim

I have a file which contains this word:

Word

when I execute this command:

:s/\(\w\)\+/#\1#/

I got ## but as I know \w matches a character. Why I did not get it in backreferencing it ?

Now for this command

:s/\(\w\)\{1,}/#\1#/ I got #d#. why it is the last character and not the first ?

VIM - Vi IMproved 7.4 Ubuntu 16.04 LTS

Upvotes: 2

Views: 84

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172520

I can reproduce this with Vim 7.4.1689 (that ships with Ubuntu 16.04 LTS), but not any longer with Vim 8.0.55. :set re=1 (i.e. switching back to the old regexp engine) fixes the problem, too. So, it seems to be a bug in the new regexp engine that in the meantime has been fixed.

Upvotes: 1

Related Questions