views:

681

answers:

5

I'm currently using a basic text editor to write my grails code. Does anyone know of a program that will automatically format code with indentation similar to indent does for C? I'd rather use a commandline program to do this but can use an IDE to format my code if that's the only option.

A: 

There is a tool recommended in this thread for this purpose. I have not tried it but maybe worth a look.

Csaba_H
+1  A: 

I am using VIM / GVIM for typing code in Groovy/Grails. it has code formatting, I just need to tell my VIM that groovy and java are similar....

and then press gg = G [enter] (format from top to bottom)

nightingale2k1
+2  A: 

Try NetBeans v.6.7 (not the current production release 6.5) with the NetBeans Groovy/Grails plugin enabled. This is a nice clean IDE interface (easier to use than Eclipse IMHO), and you can set it up to integrate with your Grails installation. You can call all your Grails tasks from the IDE, edit your code, test and run your project. Then, if you want to format your code, you just right-click in the code editor and select "Format". Easy!

Using NetBeans 6.7 FCS, there are still some issues. The one I find most frustrating is the IDE parsing Groovy as if it were Java, and flagging "errors" which are not errors in Groovy files. The file runs fine, but it is annoying to see false errors while editing. Calling Groovy classes from Java is another instance in which false errors are reported. If you can live with this, it is quite usable.
ssakl
A: 

Here's some instructions on how to get Grails working with NetBeans (couldn't submit the second URL in my last post).

A: 

the groovy eclipse plugin does a decent job of formatting groovy code. sts might be smarter about some of the grails code.

Ray Tayek