A keyboard shortcut to replace soft tab spaces with hard tabs in TextMate
September 20th, 2010Don’t you hate it when you realize you’ve been editing a file in soft-tabs mode and it’s turned into a jumble of tabs and spaces? TextMate includes a menu item to convert tabs to spaces, but it’s not accessible via an easy keyboard shortcut. Here’s a simple bundle command to replace the spaces at the beginning of each line with tabs, based on your current tab size setting.
Hat tip to Greg Bacon1 for the perl one-liner2 that makes up the bulk of this command.
In the example above (click to enlarge), I have the command bound to ctrl-shift-tab.
To do the opposite, converting tabs to spaces, use:

Among other things, Will Atwood Mitchell (wam) is the web developer for