Editing large HTML file. Would like to do something like:

:/<blockquote>/,/<\/blockquote>/s/^\(\s\s\+\)\(<[^>].\{-}>\)/\1  \2/g

So basically just trying to indent all between the tag lines. I thought this was possible, but perhaps I mangled the syntax.


  • 1
    This line works for me (at least, it does something.) Maybe the problem is that it doesn't do exactly what you wanted? In that case, can you please explain what you wanted it to do that's different from what it's doing right now? Please edit your question to add an explanation.
    – filbranden
    Commented Aug 19, 2019 at 16:10

2 Answers 2


Is sed an option?

sed -r '/<blockquote>/,/<\/blockquote>/{s/^(\s\s\+)(<[^>].\{-}>)/\1  \2/g}'
  • 1
    I mean, technically, probably, but considering this is Vi and Vim you probably should add some information regarding how you could do this with vi/vim.
    – D. Ben Knoble
    Commented Aug 20, 2019 at 3:21

If you want to indent html, use the indent operator = with the inner-tag text object it:

  1. Place your cursor on the tag whose contents need indenting
  2. Press =it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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