开发者

Java Code Formatting in Textmate

Is there a way/bundle/shortcut to format the Java Source in TextMate? (As we d开发者_如何学JAVAo with Shift+Command+F in Eclipse).


It must be

Command + Option + [

which is also Text>Indent Selection


Ctrl+Q

Although It may not be what you expect :(

alt text http://img27.imageshack.us/img27/97/capturadepantalla200910w.png


Warning: I got to the end and realized format was the one feature this DOESN'T have. I currently use this process, and then alt+tab to Eclipse to format. Neither TextMate nor Eclipse seem to have a problem with concurrently editing the same file and it works beautifully. However I realize this wasn't the original question.

I use eclim and the eclim TextMate bundle. I'm not gonna lie, you do have to run Eclipse to use it. However you can disable the GUI and run Eclipse as a headless daemon or just minimize Eclipse in case you need it for something later. It's a good compromise and well worth it for the features it provides to TextMate.

This gives me :

  • Code Completion
  • Auto-import missing classes
  • Java Rename (Refactor)
  • Window with build errors

Each of these features provides the same functionality as Eclipse itself.

Currently the bundle only supports Java, but eclim itself (which is an Eclipse plugin originally written for vim) supports many more features and languages, and is just waiting for the right person to come along and implement Eclipse features for everything.

You can find eclim here: http://eclim.org/

And the eclim bundle is in GetBundles.

If you don't have GetBundles, I recommend it. It's a bundle that allows you easily download new bundles from several repositories, all from within TextMate.

run these commands in terminal to install it:
cd ~/Library/Application\ Support/TextMate/Bundles
svn co http://svn.textmate.org/trunk/Review/Bundles/GetBundles.tmbundle/

If you prefer not to install it, the eclim textmate bundle is here: https://github.com/JulianEberius/Eclim.tmbundle

When you run the eclim setup, choose the Eclipse folder that contains 'plugins'. Then, when you launch Eclipse, go to Window->Show View->Other. Choose 'eclim' from 'eclim'. This view needs to be running for the TextMate bundle to detect the eclim server. You should see some information go through the console window, with the last line saying something like: Eclim Server Started on port 9091. If so, it should work in TextMate.

You know what, I just went to grab the keyboard shortcut for you, and realized 'format' is the one I always switch to Eclipse to use. Sorry bout that. But hey, eclim is fantastic anyway and maybe when I have some time I'll write the format command for TextMate. The source is in Python and looks relatively straightforward.


Probably what you want is this

Command + Shift + {

Works for any language

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜