开发者

How can you reformat text in TextMate

开发者 https://www.devze.com 2023-01-07 04:03 出处:网络
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.

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 开发者_Python百科: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)


Pretty indent? No way. I had no idea there was something called that. I'll be watching this thread.

For now I use apple + '[' or ']'

And make sure I have my indentions set to soft spaces.

I can't say that's exactly what you're looking for..

0

精彩评论

暂无评论...
验证码 换一张
取 消