Sublime Text 3 – wrapping selection in tag shortcut

Posted

As a front-end web developer, something I seem to end up doing a lot of times is wrapping individual lines, or wrapping a section of code with HTML tags.

For example, I might have received a text document from a client with copy for their website and I need to wrap the supplied content in the relevant HTML tags, so fairly basic stuff like <p> tags or list of menu items with <ul>/<li> structure.

Doing this one item at a time gets old really quick, so I looked into any possible shortcuts that I could use in Sublime Text (my current code editor of choice) to make this process both easier and quicker.

If you’re just wrapping a single line of code then all you need to do is as follow (Mac controls):

• Select all text
• ctrl + shift + W
• Overtype the default <p> tag with whatever you like


If the iframe video example doesn’t load, you can view it here

If you’re wanting to wrap multiple line each with their own tag then you’ll need to do the following (Mac controls):

• Select all text
• cmd + shift + L
• ctrl + shift + W
• Overtype the default <p> tag with whatever you like.


If the iframe video example doesn’t load, you can view it here

Simple!

3 Comments

Do you know how to wrap the current line without selecting the text?

@chh I believe you have to select the text first either way, but if the text is on a line by itself then that’s easy with ctrl+l

Comments are closed.