Adding the XHTML Closing Slash Automatically in Textmate

This is just one of those tips that is so amazing that I have to note it down. As many readers know, one of the rules that XML has that is not part of HTML is that all tags must be closed. Thus, the IMG and BR tags in HTML are something of a problem for the child of the marriage of XML and HTML: XHTML. The solution was to add a self-closing slash just before the closing angle bracket. For example: `
`. It turns out that my text editor of choice, [Textmate](, has the ability to do this for you:

> In TM’s Advanced preferences, in the Shell Variables segment, add a new variable named TM_XHTML with the value of / (single slash) and you will get this trailing slash everywhere you use a singleton tag, without editing any of the snippets.