Is there a command in TextMate to re-indent or format text in a file?
I use this all the time in IDE's after pasting in a block of code, removing a block, etc for re-indenting a file.
Bonus points if there is a way to pretty indent, turning this:
has_many :users, :class_name => 'Users', :dependent => :destroy
has_many :comments, :class_name => 'Comments', :dependent => :destroy
into this:
has_many :users, :class_name => 'Users', :dependent => :destroy
has_many :comments, :class_name => 'Comments', :dependent => :destroy
But even just simple reformatting would be awesome.
Not sure if it matters but I'm mostly talking about Ruby-on-Rails apps here.
Sweet!
This bundle adds it for Ruby code: http://github.com/mocoso/code-beautifier.tmbundle#readme
It only indents Ruby code (not HTML or anything else), and doesn't do the pretty indent (only regular indenting), but still - it re-indents the whole file with one command.
Edit: just realized another way to do it with a built in TextMate feature. option-apple-[ This indents one line. So if you do ctrl-a (to select all) and then option-apple-[ it has a similar effect (although it's two commands instead of one, and loses where you had the cursor)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With