Context Sensitive HTML attribute completion!!!
You'll have to have the latest copy of the support folder and the HTML bundle. I have tested this quite a bit on my machine, but if you can find a way to make it break, please let me know and I'll fix it right up.
To use: tap the space key when your caret is just before the last character in an html tag. It looks up a list of attribute to tag associations and only shows you a list of the ones that apply to the current tag that you're in.
<div TAP_SPACE_HERE> or <img TAP_SPACE_HERE />
If you type a few characters before you hit space, it'll use those characters to limit your list even further. for example:
<img onTAP_SPACE_HERE />
That will limit your list of completions to anything that starts with "on" and is applicable to the <img> tag.
Also, works with lowercase and UPPERCASE HTML tags. When you use uppercase tagnames it'll give you upper and titlecase attribute names, depending on what's appropriate.
This version DOES NOT look at your doctype, it just gives the same list for all html languages. I think I'll wait for TM2 to do the doctype thing since it'll be a lot easier then.
I'll do an official announcement with screencast and everything once people argue endlessly about the keybinding that it should use.
thomas Aylott — subtleGradient — CrazyEgg — bundleForge
On Aug 8, 2007, at 4:21 PM, Thomas Aylott (subtleGradient) wrote:
I'll do an official announcement with screencast and everything once people argue endlessly about the keybinding that it should use.
Well, I don't want to be the guy to start the argument, but space? I feel that could seriously affect my typing. I guess I don't feel it's right for any command in a TextMate bundle to touch a key like space unless I make that change. That's my two cents.
James Edward Gray II
On 8/8/07, James Edward Gray II james@grayproductions.net wrote:
Well, I don't want to be the guy to start the argument, but space? I feel that could seriously affect my typing. I guess I don't feel it's right for any command in a TextMate bundle to touch a key like space unless I make that change. That's my two cents.
Well, it only triggers if you already have a space after the tag name and before the >, so otherwise you'd be trying to put in two spaces: "<div >". How often do you do that?
And yeah: badass.
On 8/8/07, Dougal dougal@gmail.com wrote:
Well, it only triggers if you already have a space after the tag name and before the >, so otherwise you'd be trying to put in two spaces: "<div >". How often do you do that?
Spoke too soon. If you have, say, "<div id="foo"[CARET]>" and press space, then it pops up too. That's kind of annoying. Is there something that can be done about that? (Though I admittedly haven't looked at the code and know nothing about the HTML language definition, seems like it might be hard.)
Fixed. It only activates when inside of a tag and on the same line now thomas Aylott — subtleGradient — CrazyEgg — bundleForge
On Aug 8, 2007, at 7:32 PM, Dougal wrote:
Spoke too soon. If you have, say, "<div id="foo"[CARET]>" and press space, then it pops up too. That's kind of annoying. Is there something that can be done about that? (Though I admittedly haven't looked at the code and know nothing about the HTML language definition, seems like it might be hard.)
Fixed. now it works without that extra space thomas Aylott — subtleGradient — CrazyEgg — bundleForge
On Aug 8, 2007, at 7:29 PM, Dougal wrote:
Well, it only triggers if you already have a space after the tag name and before the >, so otherwise you'd be trying to put in two spaces: "<div >". How often do you do that?
And yeah: badass.
On Aug 8, 2007, at 7:22 PM, James Edward Gray II wrote:
On Aug 8, 2007, at 4:21 PM, Thomas Aylott (subtleGradient) wrote:
I'll do an official announcement with screencast and everything once people argue endlessly about the keybinding that it should use.
Well, I don't want to be the guy to start the argument, but space? I feel that could seriously affect my typing. I guess I don't feel it's right for any command in a TextMate bundle to touch a key like space unless I make that change. That's my two cents.
James Edward Gray II
Space is the standard for this. Dreamweaver, eclipse, etc... all use space. However we probly should avoid any connection to those guys as possibly ;)
How about option-escape like all other completion things? What does everyone think?
thomas Aylott — subtleGradient — CrazyEgg — bundleForge
I've never actually used Dreamweaver or Eclipse, but you are able to keep typing after you've pressed space? It just highlights the various completion options right? It's too bad we don't have a control like that for textmate.
Sudos (oops, I mean Kudos), thomas :-)
From: "Thomas Aylott (subtleGradient)" oblivious@subtlegradient.com Context Sensitive HTML attribute completion!!! To use: tap the space key when your caret is just before the last character in an html tag. It looks up a list of attribute to tag associations and only shows you a list of the ones that apply to the current tag that you're in.
"I have no fear but that the result of our experiment will be that men may be trusted to govern themselves without a master.² -- Thomas Jefferson "Always vote for principle, though you may vote alone, and you may cherish the sweetest reflection that your vote is never lost." -- John Quincy Adams
¡¡¡UPDATED!!!
This has now been changed to option-escape like every other completion thing on the mac.
<div ⌥⎋> or <img ⌥⎋ /> and <img on⌥⎋ />
I also added support for no extra space: <div⌥⎋>
And you can now activate it anywhere inside the tag and outside of another attribute, even right up against a quote mark. <div id="whatever"⌥⎋ class="whatever">
And of course, if you activate it with some characters before your caret and there's only one match returned, it just automatically inserts it without asking you to choose from among 1 choices ;)
I also fixed a few bugs where it would activate before and after the tag or on a newline, etc...
If you find any more bugs, please let me know as soon as you possibly can. Thanks!
thomas Aylott — subtleGradient — CrazyEgg — bundleForge
On Aug 8, 2007, at 5:21 PM, Thomas Aylott (subtleGradient) wrote:
Context Sensitive HTML attribute completion!!!
You'll have to have the latest copy of the support folder and the HTML bundle. I have tested this quite a bit on my machine, but if you can find a way to make it break, please let me know and I'll fix it right up.
To use: tap the space key when your caret is just before the last character in an html tag. It looks up a list of attribute to tag associations and only shows you a list of the ones that apply to the current tag that you're in.
<div TAP_SPACE_HERE> or <img TAP_SPACE_HERE />
If you type a few characters before you hit space, it'll use those characters to limit your list even further. for example:
<img onTAP_SPACE_HERE />
That will limit your list of completions to anything that starts with "on" and is applicable to the <img> tag.
Also, works with lowercase and UPPERCASE HTML tags. When you use uppercase tagnames it'll give you upper and titlecase attribute names, depending on what's appropriate.
This version DOES NOT look at your doctype, it just gives the same list for all html languages. I think I'll wait for TM2 to do the doctype thing since it'll be a lot easier then.
I'll do an official announcement with screencast and everything once people argue endlessly about the keybinding that it should use.
thomas Aylott — subtleGradient — CrazyEgg — bundleForge