Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having a problem with a regular expression on vim. I have a pattern as follows: http:\/\/\(\w\+\.\?\)\+ [matches http://(AS MANY WORDS FOLLOWED BY DOT OR NOT ENCOUNTERS) e.g.]

I have a text as follows:

I am trying to make this substitution on it:


and the result is /wd3 (Notice the white space inserted at the end of the replacement)

How can I avoid having this inserted space? I am afraid is a bug in the regexp engine but I am not sure.

share|improve this question

I can't reproduce this. The regex is still not correct however, it must be \w\+.



results in the following for me.

Tip: a much cleaner version of your regex can be achieved by using vim's 'very magic' regex mode (c.f. :help regex)

share|improve this answer
Sorry you are right \w\+ is as in the beggining of the question, I have just fixed it in the post – poissonbreaker Oct 14 '12 at 8:45
I am afraid is exactly the same case. Maybe is a failure in the version of VIM I am using. Thanks for your answer. I can not give you any points yet since I have no reputation for doing it, sorry. – poissonbreaker Oct 14 '12 at 8:52
I'm using vim 7.3 mit patches 1-661 (check vim --version) – buergi Oct 14 '12 at 9:09
Vi Improved 7.2 – poissonbreaker Oct 14 '12 at 10:00
Great. Your IMproved version worked like a charm. I hadn't heard of that piece of magic. Excellent. I guess the problem is with the VIm version, because in yours the first way worked, but still is strange that the second had worked for me also. Anyway thanks for your tips, were very helpfull. – poissonbreaker Oct 14 '12 at 10:09

You must log in to answer this question.

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