d1qphg
Last Updated: December 26, 2018
·
84.9K
· 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

20

Ctrl-Shift-W on a mac

over 1 year ago ·
1191

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 ·
1200

@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 ·
3623

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

over 1 year ago ·
5619

Really useful. thanks

over 1 year ago ·
5620

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

over 1 year ago ·
6352

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

over 1 year ago ·
7136

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

over 1 year ago ·
10211

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 ·
11053

@epocsquadron You made my day!

over 1 year ago ·
13681

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 ·
14782

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

over 1 year ago ·
25982

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 ·
27841

Alt + F4 on windows.

over 1 year ago ·