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?


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.
| improve this answer | |

You can do it with the surround plugin for VIM: https://github.com/tpope/vim-surround

| improve this answer | |

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.