Sublime Forum

HTMLAttributes update

#1

Hello. I made two small changes to my HTMLAttributes, available via PackageControl.

I swapped the order of **value **and **valign **so that if I type v and press TAB it produces value="" by default, with the cursor between the quotes. (Having typed the value we can press TAB again to skip out of the quotes :smile: .)

I’ve moved deprecated attributes further down in the list, although still in alphabetical order. This means, the more you use the attributes, the less likely deprecated items will be suggested near the top of the completions list.

If anyone has found little niggles please let me know as a slight re-ordering might fix these. Andy.

0 Likes

#2

This look great, thanks for making it. Is it context aware? By that I mean, it shows a value attr on the

element when it shouldn’t (w3.org/TR/html4/struct/global.html#h-7.5.4). I don’t mind because I know which attrs to use but I thought I would ask…
0 Likes

#3

Hello @MrMartineau and thank you.

The attributes are not context aware… currently. I find them very neat and efficient though; if we already know the attributes and where they are applicable, I/we can more or less type a single letter and TAB into, and out of, the quotes for the value.

They *could *be made context aware: I would create a .py file and read the characters to the left of the cursor until I meet the opening tag <. I would need to organise the attributes into different lists and append these sub-lists until the correct list is available for the current tag.

It would need a bit of planning to make sure the generated list(s) are complete and correct, but it’s do-able. All I’m lacking is the impetus (enthusiasm :laughing: !). But I’ve noted your interest. Andy.

0 Likes

#4

On reflection I’m not sure that it would be worth trying to make them context-sensitive:

There are 160-ish completions, 20+ of which are deprecated;
30+ are HTML5 and subject to change/re-interpretation;
Where attributes are only applicable to one or two elements, this is noted in the completions’ description;
Many of the remaining completions are global (apply to all elements).

The two of most interest are **name **and value. It would be *nice *if these were only available in the right context. Then again, if someone is using XML/XHTML or a custom DTD, then it is possible that they should still display. (Although, I don’t think they display in XML anyway :smile: .)

0 Likes

#5

I think you’re right. I don’t think you need to make it context sensitive. Thanks again for the plugin

0 Likes

#6

You are welcome; enjoy!

0 Likes

#7

Hello. I’ve updated my HTMLAttributes plug-in, available via Package Control, as follows:

For the type="" attribute you can just type the letter ‘j’ to produce “text/javascript” or ‘cs’ for “text/css” - then Tab past the quotes.

Just some reminders:

The intention is that we only need to type one or two letters and press Tab. For example, type ‘i’ then Tab should produce id="|", similarly typing ‘v’ then Tab should produce value="|". Type your value and press Tab once more to continue.

If the wrong attribute appears, such as valign instead of value, then Backspace and type valu, then Tab, or press Ctrl-Space to show the full list. Once you’ve used the same attribute a few times ST will remember your choice.

If you are less familiar with the names of the various attributes then just use Ctrl-Space to show the list, until they are more familiar to you.


Someone asked me recently whether it is possible for the attributes to appear automatically, in the completions’ list. This may be possible by changing some settings, but I don’t really see this as the intended usage for my package.

Enjoy! Andy.

0 Likes

#8

PS You can type abbreviations such as omv for onmouseover="" (or even** ov**) but you may initially have to press Tab twice for it to be recognised. Andy.

0 Likes