Reputation: 698
I want to search and replace something like this:
"foo : foo"
to
"foo"
But of course, I need to that with a regex.
I have tried to use the below S&R command, but it seems that using backref in the searched string is not working:
%s/\(a-z\)\zs : \1\ze//
Any idea how can I do that?
Thanks.
Upvotes: 0
Views: 58
Reputation: 94483
%s/\([a-z]\+\)\zs : \1\ze//
[a-z]
means "any character", \+
means "repeated 1+ time".
\1 works perfectly!
Upvotes: 2