4

I would like, using vim-surround to convert this

            <p>
            ^currsor
              Issues reported by users from the
              <a href="https://re.fr"> https://re.fr</a>
              they will create an issue.
            </p>

into that

            <h1>
              Issues reported by users from the
              <a href="https://re.fr"> https://re.fr</a>
              they will create an issue.
            </h1>

I've been using in command mode: cs<<h1> and I get

            <h1>p</h1>
            ^currsor
              Issues reported by users from the
              <a href="https://re.fr"> https://re.fr</a>
              they will create an issue.
            </p>

from: https://stackoverflow.com/questions/65908860/vim-change-multiline-html-tags-with-vim-surround

2
  • I experimented with it a little bit... It looks like cst<h1> using t instead of < helps, though in my case it reindents the block as well. It looks like < was supposed to be a synonym for t, but they don't seem to behave the same... Still not 100% sure of what's happening here.
    – filbranden
    Jan 26, 2021 at 21:36
  • 1
    The thing is, the text-object i< actually use the part inside the brackets (the p part of the tag), so that could be related.
    – D. Ben Knoble
    Jan 26, 2021 at 21:49

1 Answer 1

1

Without using surround with just vanilla vim8 I got this

vat this select the block including the p tag then I call

:'<,'>s/p>/h1>/

and I got (by the way it does not break the indentation):

            <h1>                                                                                    
              Issues reported by users from the                                                     
              <a href="https://re.fr"> https://re.fr</a>                                            
              they will create an issue.                                                            
            </h1>     

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.