Last Updated: September 29, 2021
·
100.1K
· mattam

Sublime Text: Wrapping content with tag

To wrap your selected content with a html tag, just selected your text, then press Alt-Shift-W. You'll then have the option to fill in the front and back tag simultaneously.

14 Responses
Add your response

Ctrl-Shift-W on a mac

over 1 year ago ·

Turns out you can use a zencoding-like syntax with this! For example, if you select text, hit the key combo, then type span.this.is.awesome#stuff>a[href="http://my.mind.is.blo.wn/index.html"], your text will be wrapped as expected with a span with classes "this" "is" and "awesome and an id of "stuff", and inside that, but still wrapping your text, an a tag with an href value matching the above!

I do have the zencoding plugin enabled, so this may be specific to that extension. Still it is quite awesome!

over 1 year ago ·

@epocsquadron You're right, if you have zencoding and you're doing this on an html file, they key combo will bring up the zencoding input box for you to use. Awesome tip!

over 1 year ago ·

In addition, Ctrl + Shift + Enter does the same operations. Nice tip. Thanks..

over 1 year ago ·

Really useful. thanks

over 1 year ago ·

@aliemreeee I don't think so! It just add a new line before the content.

over 1 year ago ·

Btw, don't try Ctrl-Shift-W on Windows.

over 1 year ago ·

ctrl-shift-g works for me on both Ubuntu and windows. I have emmet installed.

over 1 year ago ·

How does it know which tag to use?

It doesn't ask me for a tag, it just knew that I wanted a P-tag in my particular case. Is there a place to set it?

Thanks, rvinay88, ctrl-g was the option I was after.

over 1 year ago ·

@epocsquadron You made my day!

over 1 year ago ·

Further to what @epocsquadron said - if you want zen-coding in Sublime Text 2/3 get the Emmet plugin: http://docs.emmet.io/

over 1 year ago ·

Great tip that just added at least another 20 years of spare time onto my life!!!!!

over 1 year ago ·

CTRL + SHIFT + W on Mac. It does default to

but you can just start typing the tag you want and both open and close tags will update.

over 1 year ago ·

Alt + F4 on windows.

over 1 year ago ·