| 2022-10-07
How to Surround Text With an HTML Element With Vim
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:
This is a line of text.
javascript
And you wanted to wrap it in a div, you would highlight the text and press S <div>
to get:
<div>This is a line of text.</div>
javascript
Thanks for reading. If you enjoyed this post, I invite you to explore more of my site. I write about web development, programming, and other fun stuff.