| 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:

    1. Enter visual mode by pressing the v key.

    2. Highlight the text you want to wrap.
    3. Press S (capital S).

    4. 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.

    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>

    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.