Created
March 19, 2010 16:07
-
-
Save cowboy/337716 to your computer and use it in GitHub Desktop.
Better indentation for TextMate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Indent with opt-tab | |
### http://benalman.com/grab/6e0f7b.png | |
#!/usr/bin/perl -w | |
$tab_soft = ' ' x $ENV{'TM_TAB_SIZE'}; | |
$tab_hard = "\t"; | |
$tab = $ENV{'TM_SOFT_TABS'} eq "YES" ? $tab_soft : $tab_hard; | |
while (<STDIN>) { | |
s/(?:^|\G)(?:$tab_soft|$tab_hard)/$tab/g; | |
print "$tab$_"; | |
} | |
### Un-Indent with shift-tab | |
### http://benalman.com/grab/ac29aa.png | |
#!/usr/bin/perl -w | |
$tab_soft = ' ' x $ENV{'TM_TAB_SIZE'}; | |
$tab_hard = "\t"; | |
$tab = $ENV{'TM_SOFT_TABS'} eq "YES" ? $tab_soft : $tab_hard; | |
while (<STDIN>) { | |
s/(?:^|\G)(?:$tab_soft|$tab_hard)/$tab/g; | |
s/^(?:$tab_soft|$tab_hard)//; | |
print $_; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment