TextMate Haml Indentation
November 27th, 2007
TextMate has this clever feature where when you paste something, it is adjusted to the same indentation as the preceding text. This works wonderfully in languages like Ruby that have block ending delimiters. However, in certain languages (Haml, Sass, Yaml, Python), you indicate the end of a logical block by indentation alone. The result is that when you copy and paste code, the indentation feature is more often wrong than it is right.
You can turn off the indentation feature from the preferences pane, but then you lose a useful feature when using languages like Ruby. TextMate also provides a Paste Without Re-Indent feature, but it’s rather a pain to type Ctrl+Cmd+V every time I want to paste. My solution was to make a macro which calls Paste Without Re-Indent, and map it to Cmd+V in Haml and Yaml files. The macro is available for download.

Sorry, comments are closed for this article.