According to Tim Pope, we can do the following:
Finally, let's try out visual mode.
Press a capital V (for linewise visual mode) followed by S<p class="important">.
And you get this
<p class="important">
<em>Hello</em> world!
</p>
I tried and it works. But how can I repeat that command on many other
visual blocks? I tried .
but didn't work.
Update:
With this text:
foo
foo
foo
I tried this qqgvS<p class="important">q
. It correctly gives
<p class="important">
foo
</p>
foo
foo
But when I repeat with this @q
(with cursor on f letter of second row) it gives this:
<p>
<p class="important">
foo
</p>
</p>
foo
foo
Instead of
<p class="important">
foo
</p>
<p class="important">
foo
</p>
foo
What's the right way to do it?
I usually do that with something like:
:'<,'>norm! yss<p>
As an alternative, you could record a macro and play it back on each line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With