Home Download Buy Blog Forum Support

How do I wrap selection in a tag?

How do I wrap selection in a tag?

Postby firefusion on Sun Oct 25, 2009 6:00 pm

I've recently converted from E-Texteditor and one of the only features i miss it the ablity to wrap a selection in a html tag.

I would highlight the selection > press ctrl alt w > and type the tag letters "p". Is this possible with sublime?
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: How do I wrap selection in a tag?

Postby ilya on Sun Oct 25, 2009 6:09 pm

In Sublime Text all easier — highlight the selection, type tag name and press the tab key.
ilya
 
Posts: 122
Joined: Fri Sep 11, 2009 8:32 pm

Re: How do I wrap selection in a tag?

Postby firefusion on Sun Oct 25, 2009 9:24 pm

Very cool :)

Thanks!
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: How do I wrap selection in a tag?

Postby barty on Mon Oct 26, 2009 4:33 am

when I do that, it just replaces the selection with the tag (e.g., 'p') and tab, literally. syntax is set to html.
barty
 
Posts: 47
Joined: Thu Sep 10, 2009 5:39 am

Re: How do I wrap selection in a tag?

Postby ilya on Mon Oct 26, 2009 8:39 am

Firstly it replaces the selection with typed tag, but after pressing tab key the selection reappears already inside the tag.

Or something I do not understand and this functionality is dependent on any plug-ins? Image
ilya
 
Posts: 122
Joined: Fri Sep 11, 2009 8:32 pm

Re: How do I wrap selection in a tag?

Postby jps on Mon Oct 26, 2009 1:05 pm

barty wrote:when I do that, it just replaces the selection with the tag (e.g., 'p') and tab, literally. syntax is set to html.


Wrapping the text as ilya described is the default behaviour, perhaps this has been changed for you by a plugin.
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: How do I wrap selection in a tag?

Postby barty on Mon Oct 26, 2009 3:55 pm

Jon, I think I found a possible bug.

I did a clean reinstall to find where the problem is and traced it to my keymap file. If I use mine keymap instead of Default, it breaks the tag wrap behavior. So I copied Default.sublime-keymap to temp.sublime-keymap to get a fresh restart. But without changing anything else, just setting

keymap temp

in Application.sublime-options breaks the tag wrap.

Then I copied and pasted my keymap file into Default.sublime-keymap and set it back to

keymap Default

and the wrap tag behavior is OK!
barty
 
Posts: 47
Joined: Thu Sep 10, 2009 5:39 am

Re: How do I wrap selection in a tag?

Postby EJ12N on Tue Oct 27, 2009 9:14 pm

if you take a look in the PowerUser package I provided I made a textmatetag.sublime-snippet...

basically it allows you to wrap an elemnt in a tag just exactly as it works in textmate or e-text
and for those that don't want to bother downloading the package here it is...

Code: Select all
<!-- Insert open/close tab - textmate way -->
  <binding key="ctrl+comma" command="insertSnippet 'Packages/PowerUser/Snippets/HTML/textmate_tag.sublime-snippet'">
    <context name="selector" value="text.html - source, text.xml"/>
  </binding>


and the snippet...
Code: Select all
<snippet>
   <content><![CDATA[<${1:p}>${0:$SELECTION}</${1/\s.*//}>]]></content>
</snippet>


the regex in the snippet makes sure that when you type a tag with attributes the attributes don't get mirrored in the closing tag... default behavior in sublime it does... not good :P
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: How do I wrap selection in a tag?

Postby barty on Thu Oct 29, 2009 9:17 pm

barty wrote:Jon, I think I found a possible bug.

I did a clean reinstall to find where the problem is and traced it to my keymap file. If I use mine keymap instead of Default, it breaks the tag wrap behavior. So I copied Default.sublime-keymap to temp.sublime-keymap to get a fresh restart. But without changing anything else, just setting

keymap temp

in Application.sublime-options breaks the tag wrap.

Then I copied and pasted my keymap file into Default.sublime-keymap and set it back to

keymap Default

and the wrap tag behavior is OK!


I figured out my problem: the wrap tag function requires Default.sublime-keymap in the html package. When I change the keymap file to something other than Default, that file no longer gets loaded so the wrap tag feature (and others) no longer works.
barty
 
Posts: 47
Joined: Thu Sep 10, 2009 5:39 am

Re: How do I wrap selection in a tag?

Postby poporon on Mon Feb 28, 2011 9:36 am

Hi there!

I realize this is an old thread but I'm trying to achieve the same thing as the original poster and I'm having the same problems except that I have a clean install of Sublime Text 2. I'm on OSX and I looked in ~/Library/Application Support/Sublime Text 2 and opened files that made sense to me but I can't figure it out. Any help/pointers you guys can give me would be great!

Thanks :)
poporon
 
Posts: 1
Joined: Mon Feb 28, 2011 9:26 am

Next

Return to Technical Support

Who is online

Users browsing this forum: faye, Google [Bot] and 25 guests