2

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:

:s:\(\d\):<sup>\1<\/sup>

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

2 Answers 2

4

You should try:

:s/\(\d\+\)/<sup>\1<\/sup>/g

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.
0
2

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

2

You must log in to answer this question.

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