views:

390

answers:

1

Is it possible for TextMate to syntax highlight the opening and closing tags of your current caret location? And I am talking about constantly, not by pressing a key combo.

Furthermore, if it possible, how can I do it? There doesn't seem to be any way that I know of except by using selectors in the theme, but I don't know if selectors can be context-sensitive.

+1  A: 

currently, the TextMate language grammar has no concept of cursor position. Therefore, this is not achievable right now.

A workaround that I use is to define macros that select a block of text whose boundaries I define with regular expressions. You have to be handy with regular expressions, but you can make it work.

Essentially, record a new macro (option-command-m), use the find dialog to search for the beginning of the tag. Then, use the find dialog and provide a reg-ex that will match the entire contents you want to select. Press option-command-m again to stop the macro, and then save the macro to a bundle.

An example here:

http://github.com/timcharper/vines.tmbundle/blob/master/Macros/Select%20Tag.tmMacro

Tim

Tim Harper
Thanks for the information. I wonder if you could have this macro execute every time you move the caret in the editor but I would assume this would slow things down.
subkamran