0

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.

Thanks,

  • 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 Aug 19 at 16:10
1

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 Aug 20 at 3:21
1

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, privacy policy and cookie policy

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