Sublime Forum

HTML snippets no longer working


Problem: It appears as though the only HTML snippets that still work in ST2 are script_tag and style_tag, since they have an explicit tabTrigger. All others, like html and elementid don’t work anymore, despite the fact that as far as I can tell the snippets themselves are unaltered from those in ST1.

Steps to reproduce: Create a blank .html document. Type html and press tab. This produces the word html followed by four spaces (or a tab, depending on your settings) rather than the expected document skeleton.



I can confirm this on all platforms.
Windows 7
OSX 1.6.6
Ubuntu 10.10



I haven’t looked into this but I just figured they weren’t built in. Aren’t they just tied into Zencoding or the WebDeveloper packages? Might need to wait for those to get ported or setup some snippets of your own in the meantime.



They worked in ST1 and I had neither of those two packages installed.



I’ve doublechecked this and these snippets relied in regex-based keybindings. I took a quick glance, and I couldn’t find any examples of regex-based keybindings in v2, so either they are not implemented or maybe the syntax has changed…



Yeah, regex based key bindings are not yet implemented in Sublime Text 2. It’s likely the HTML snippets will end up working via a different mechanism this time around.



That’s cool to hear, because, not surprisingly, they precisely seemed to mess up other regex based keybindings (for instance, a watered-down Vim emulation).



If you’re going to be using a different mechanism anyway, my suggestion would be to bind a script to the tab key in the context of html and xml files that looks at the preceding characters. If it is a valid tag name (with optional attributes), such as body, div#menu or p.caption#caption1, it expands it to the tag. In all other cases, it inserts a tab. This has two advantages over the current approach: you no longer have to type everything in a short timeframe and you can use backspace if you make a mistake.



Sounds like Zen Coding to me :smile: would love to see this in Sublime!



New scope text.html. Just try it. Works for me.

1 Like