Home Download Buy Blog Forum Support

CloseTagCommand — closes closest unclosed tag

Re: CloseTagCommand — closes closest unclosed tag

Postby indiver on Sat Mar 05, 2011 10:10 am

I've just followed through the instructions above on a Mac. But when I try to run it using CTRL-period, I get the following output in the console:

Code: Select all
no command for selector: noop:


I've copied the code in ~/Library/Application Support/Sublime Text 2/Packages/User in a file named: close_tag.py

And added the following line to user key bindings:

Code: Select all
{ "keys": ["ctrl+period"], "command": "close_tag" }


Am I missing something?
indiver
 
Posts: 30
Joined: Fri Mar 04, 2011 5:40 am
Location: Auckland, New Zealand

Re: CloseTagCommand — closes closest unclosed tag

Postby jps on Mon Mar 07, 2011 12:45 am

period isn't bindable in OS X, however the next version is getting an input handling refresh, and it'll be bindable as "ctrl+." then. Then dev build will be available soon.
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: CloseTagCommand — closes closest unclosed tag

Postby Barium on Wed Mar 09, 2011 1:59 pm

You should take care when using regular expressions for parsing HTML, it is generally not a good idea. There are other far better tools for that purpose. Parsing HTML with regular expressions will only add to your list of problems. You might find this post interesting on Stack Overflow: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
Barium
 
Posts: 25
Joined: Wed Mar 09, 2011 1:40 pm

Re: CloseTagCommand — closes closest unclosed tag

Postby gpfsmurf on Tue Mar 15, 2011 11:57 pm

Barium wrote:There are other far better tools for that purpose.

Which one?

For the purpose of this plugin, it will work the majority of the time. It's meant to be called manually so I think it's more than good enough.

But if you know of a good parser than can be easily integrated, it could lead to for interesting plugins. The parsers I've used are meant to extract information: they return a tree that doesn't have the character position of the nodes in the document.
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: CloseTagCommand — closes closest unclosed tag

Postby pflynny on Sun May 01, 2011 11:26 am

indiver wrote:I've just followed through the instructions above on a Mac. But when I try to run it using CTRL-period, I get the following output in the console:

Code: Select all
no command for selector: noop:


I've copied the code in ~/Library/Application Support/Sublime Text 2/Packages/User in a file named: close_tag.py

And added the following line to user key bindings:

Code: Select all
{ "keys": ["ctrl+period"], "command": "close_tag" }


Am I missing something?


Having the same issues, any info on how we can get this working? Such a handy Textmate feature.

:)
pflynny
 
Posts: 5
Joined: Sun May 01, 2011 11:24 am

Re: CloseTagCommand — closes closest unclosed tag

Postby karbassi on Fri May 20, 2011 3:38 am

Code: Select all
[
    { "keys": ["super+."], "command": "close_tag" }
]


Use the above.
karbassi
 
Posts: 2
Joined: Fri May 20, 2011 3:36 am

Re: CloseTagCommand — closes closest unclosed tag

Postby sheldon on Mon Jul 04, 2011 9:40 am

thanks for this, really helped me a lot moving from textmate.
sheldon
 
Posts: 1
Joined: Mon Jul 04, 2011 9:39 am

Re: CloseTagCommand — closes closest unclosed tag

Postby wastek on Tue Aug 09, 2011 9:46 pm

If anybody is interested I have created a plugin that auto closes tags when entering "</" (if mapped to the "/" key).
Please have a look at http://github.com/kihlstrom/CloseTagOnSlash
Last edited by wastek on Sun Nov 13, 2011 1:53 pm, edited 1 time in total.
wastek
 
Posts: 6
Joined: Tue Aug 09, 2011 9:40 pm

Re: CloseTagCommand — closes closest unclosed tag

Postby oriceon on Wed Aug 10, 2011 6:53 am

@wastek THANKS! I love this plugin and for me is in top 5 sublime plugins :)
oriceon
 
Posts: 56
Joined: Tue Jun 14, 2011 6:06 am

Re: CloseTagCommand — closes closest unclosed tag

Postby voxmea on Wed Aug 10, 2011 5:09 pm

@wastek Good stuff, thanks for sharing. I made the following change which removes an extra closing '>'.

Code: Select all
         if tag is not None and not tag.endswith('>'):
            self.view.insert(edit, self.view.sel()[0].begin(), tag + '>')
         elif tag is not None:
            self.view.insert(edit, self.view.sel()[0].begin(), tag)
voxmea
 
Posts: 28
Joined: Fri Feb 04, 2011 10:02 pm

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 11 guests