d1qphg
Last Updated: January 21, 2017
·
61.41K
· mattam
587a1eae4aad540a9664f7cd19fb5a7e

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
Foto 6

Ctrl-Shift-W on a mac

over 1 year ago ·
1191
805d24696328089e04e40710cbc109f1

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
04b056e843c7f0e4c7e97e36174e43b4

@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
5f8886b89696efeb3dcebeee856a1e45

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

over 1 year ago ·
10211
3553d7b819d7dcbab580f6a3b84cbf91

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
70034fa76ec3ada7dc95ecb8dc01f74f

@epocsquadron You made my day!

over 1 year ago ·
13681
A11648c2bb6ab92e84d9d19e4f566784

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
77facb9235772ebd506e15c680fe8e73

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

over 1 year ago ·
25982
None

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.

9 months ago ·