Get Social

How-To Use Valid XHTML Tags in TextMate

Written by | Posted on March 27th, 2007

Here’s a tip I just now found out about. In TextMate, the HTML bundle has a ton of available snippets. Unfortunately, they don’t automatically add the closing trailing slash for certain elements. For example, instead of inserting

<br/> or <input type="text"/>

TextMate inserts

<br> or <input type="text">

(Note the missing trailing slashes.)

You can change this behavior by going to

  1. TextMate Preferences → Advaned → Shell Variables
  2. Create a new variable called “TM_XHTML” with value “/” (no quotes)

Now TextMate will output valid XHTML when you use the HTML bundle. Here’s a screenshot showing the correct setup. Hope this helps!

TextMate Advanced Preferenes

Comments