indent alignment of variable names...

Is there any way I can simply align my variables as below? Or perhaps there's a way to align by the '=' sign.

OpsTransaction transaction = null;
GLAccountList gLAccountList = null;
OpsGLAccountExt glAccountExt = null;
List itemOIDList = new ArrayList();
List secondList = new ArrayList();
OID oid;

I used to be able to do this on emacs, but I can't seem to find it in the docs with idea, though it may be that I'm searching on the wrong words...

Joe

14 comments

The tabifier plugin aligns declarations as I think you want them (the alignment was lost in your original message, I suspect).

So you could have:


There are two versions, one for the last official release (3.0.x) and one for the EAP.

-Dave

0

Thanks, that was just what I was after. One minor detail though...

I read in the docs that I can set the behaviour to 'reformat whole file' if there's no text selected. That sounded great to me and I read that I had to edit the other.xml file to affect default properties for plugins (if they don't have their own config file). But whenever I make a change there, it's ignored and the file other.xml file is changed back automatically

]]>

I keep changing that last variable to true, idea keeps changing it back.

Also, I've been trying to use it with the reformat plugin (as Tabifier said it works well with that) but the reformat plugin doesn't appear to be working at all for me. I installed Reformat-0.6.1.jar in my plugin directory and figured that was all there was to it. Am I missing something obvious.

I know these are 2 separate questions but I thought I'd throw them out together in case I got lucky...

cheers!

0

Whenever you take focus away from IDEA, the plugins get called to write their state. I'm guessing that is what is happening to you -- you edit the file, go back to IDEA, then go to look at the file again (at which point your changes are overwritten!) If you change that file before running IDEA, the state should keep; or you can just go to the tabifier settings dialog and change it there. The settings are permanent.

Regarding the reformat plugin -- have you stopped and restarted IDEA after dropping it into the plugin directory? IDEA doesn't find plugins dynamically, only at startup.

Let me know -
-Dave

0

Thanks for the tabifier tip. I didn't realize there was a settings option for it. That seems to have fixed the problem of making the 'non-selected' behaviour tabify the whole file.

However, the Reformat-0.6.1 plugin just doesn't work for me. I'm using the full release (build# 706). I've taken out that plugin and ctrl-alt-L works fine again, though with the confirmation dialog and without calling tabify (which I'd really like)

0

Good - sounds like you're underway. I'm not sure where you read that you have to set permanent plugin values in that other.xml file; most of the plugins seem to have settings panels of their own. If they didn't, though, you probably would have to put those values in manually.

It looks like the latest release of the Reformat plugin that works with build 706 is 0.5.1 (#705, #833) - Jun 20, 2003. (I found that information at http://www.intellij.org/twiki/bin/view/Main/ReformatPlugin.)

I'm surprised that the rearranger plugin is working with build 706; there's one thing they changed between last official release and current EAP builds that I expect would prevent it (it's the way to "commit" a document). But more power to you if it works!

-Dave

0

thanks Dave,

BTW - I haven't done any research on the EAP builds, but are you a strong proponent of them? Are they 'buggy'? If not, then I think I'll take the time to research what they offer and maybe I'll take the leap into those little charted waters...

0

I'm using the EAP builds exclusively now. The features are improved and apart from occasional performance problems it has worked well for me. There seems to be a huge and vocal following of the EAP builds, if you watch the EAP forum or bug or feature request forums. In other words, at this point, the waters have been pretty well charted! And shoals are identified quickly (I mean within minutes of release -- it's almost funny!)

I went to the EAP builds when I was enhancing the tabifier plugin (still underway) because it was getting to be impossible to write a plugin that used their internal "program structure information" tree and worked with both release and EAP builds.

They're pretty good at not releasing an unstable build, IMHO.

-Dave

0

One more tabbing question...

I've got one particularly long class that I want to 'tabify' in the following way. I'd like all method calls that extend beyond 80 chars to have each parameter on a new line and tabified. Also the last parameter is an array that I'd like to have shrunk into one line. so...

entry = new RouterEntry("ConfigurationManager.getUserTypeByOID", "opsx.server.kernel.manager.OpsConfigurationManager", "getUserTypeByOID", new int[]
); would become... entry = new RouterEntry("ConfigurationManager.getUserTypeByOID", "opsx.server.kernel.manager.OpsConfigurationManager", "getUserTypeByOID", new int[] );

Not sure if the alignment will work in this post, but I'm sure you get my meaning.

Tabifier doesn't do it, but I think it's a reasonable code formatting request (except maybe the part about the array)

What do you think?

0

They've added part of that feature to the EAP already -- under Code Style options. It will align each of the parameters to the column just after the left parend. The new version of tabifier will take that and "sub-align" the individual parameters if there's any more to do -- in the example you supplied, I don't see any.

The new version of the tabifier will also align method declaration parameters, e.g.


becomes (at your option)

0

Actually, that's also in the main build. But does the EAP break down long lines automatically, as the main release will only align parameters after I manually break the lines.

0

Yes, under IDE Settings...Code Style...Work in progress, there are a number of wrapping functions. The one for method calls offers:

You can also specify a new line (or not) after the open and close parends.

There's nothing there to do your array example, although Tools...Code Layout might fix it.

-Dave

0

Right!

I'm convinced. I'm installing the EAP later today. Is there a build you'd recommend or should I just stick to the latest.

0

The latest build, 944, has been working well for me. I think they're about to release a new one ("any day now" :) but no reason to wait.

Good luck,
-Dave

0

This is the feature request in the tracker:
http://www.intellij.net/tracker/idea/viewSCR?publicId=3014
If you want to see alignment make it into the main build, please go ahead and vote for it!
Unfortunately I cannot use the plugin, because my whole team has to standardize on code formatting and it was already a PITA to get everybody to use the same IDEA configuration files...

0

Please sign in to leave a comment.