[TxMt] Start/end tag from previous word (ctr+cmd+space)

Allan Odgaard allan at macromates.com
Sun Sep 25 18:31:24 UTC 2005

On 25/09/2005, at 11.39, Andreas Wahlin wrote:

> [...] but when I do the same on a h1 tag, the result becomes
> <h1>
> |</h1>

This isn't the macro. The macro is just a regexp replace on the  
current word to <$1></$1>, though catching those tags w/o closing tag  
and using a condition in the replace string -- Michael Sheets has  
flirted with the thought of looking up the tag name and insert a  
customized snippet instead.

As for the extra indent and newline, this is done by having the HTML  
language grammar match a select set of open/close tag pairs (those  
which were part of the increase indent pattern) -- the rule is  
meta.tag.html, and it should be quite easy to add more tag names (or  
even make it a catch-all instead).

The rule assigns a special scope to the position between the two tags  
(meta.scope.between-tag-pair.html) and then the “Smart return/indent  
for tag pairs” snippet is set to insert the extra indent + newline,  
assigned return as key equivalent, and have the scope set to  

So that's how this smart newline + indent is achieved for <tag></tag>  

More information about the textmate mailing list