Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 have a bunch of text I need to format via HTML, my main problem being that there's a bunch of digits at the beginning of certain words that I need to wrap with HTML tags. I'm trying to think up a vim regex that can help me achieve this but the furthest I've gotten is this:


This however only changes the first number in the line and not anything after that. Any ideas?

share|improve this question
up vote 4 down vote accepted

You should try:


The 2 problems you had with your command were:

  • \d matches only one digit. Add a + do match more
  • The /g in the end allows the substitution to continue after the first match.
share|improve this answer
Works like a charm, much obliged. Can't accept yet due to some strange 9 minute magic. – CSED Sep 20 '12 at 14:36
Glad to help :) – m4573r Sep 20 '12 at 14:39

You can do it with the surround plugin for VIM:

share|improve this answer
Looks useful, I'll give it a shot. Thanks. – CSED Sep 20 '12 at 14:55
Welcome to Super User! Your answer does not provide any information why or how the program can answer the question. Please take a look at these suggestions on how to provide great software recommendations. – Daniel Beck Sep 20 '12 at 15:31
Thanks for the suggestions. I though that the link was self-explanatory. – Atropo Sep 25 '12 at 10:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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