2024-10-02 Programming
How to Surround Text With an HTML Element With Vim
By O. Wolfson
If you're working with VS Code and the VsCode Vim extension, you can use Vim commands to quickly wrap a line of text in an HTML element. Here's how to do it:
Enter visual mode by pressing the
v
key.- Highlight the text you want to wrap.
Press
S
(capital S).Enter the HTML element you want to wrap the selected text with, like this for
<div>
:<div>
.
This will wrap the selected text in the specified HTML element. For example, if you had the following line of text:
javascriptThis is a line of text.
And you wanted to wrap it in a div, you would highlight the text and press S <div>
to get:
javascript<div>This is a line of text.</div>