code reformatting

Hi,

I do a lot of contracting work and adjusting to each company's code formatting style is getting quite annoying (especially when working on several projects at the same time). I'd like to be able to do the following:

1. Ability to define multiple coding style formats.
2. Display/edit files in IDE's editor using my preferred style.
3. When files are saved, format them using the company's style (so that external SCM-based diff tools work correctly).
4. Reformat files before submitting to SCM using the company's style.
5. When using any of SCM diff tools normalize formatting either to company's style or to my preferred style.

I know that IDEA can do #1 and #4 (though, I can't specify what style I want to use). Is there a way I can do any of the others? If not, is there a chance these are added in a feature version of IDEA?


Thanks
Dmitry

4 comments
Comment actions Permalink

Not exactly what you're after, but try CTRL-` in the editor to quickly switch
between styles. Also, you can set the code style on a per-project basis;
if you do that don't most of your problems go away (apart from #2)?

Hi,

I do a lot of contracting work and adjusting to each company's code
formatting style is getting quite annoying (especially when working on
several projects at the same time). I'd like to be able to do the
following:

1. Ability to define multiple coding style formats.

2. Display/edit files in IDE's editor using my preferred style.

3. When files are saved, format them using the company's style (so
that external SCM-based diff tools work correctly).

4. Reformat files before submitting to SCM using the company's style.

5. When using any of SCM diff tools normalize formatting either to
company's style or to my preferred style.

I know that IDEA can do #1 and #4 (though, I can't specify what style
I want to use). Is there a way I can do any of the others? If not,
is there a chance these are added in a feature version of IDEA?

Thanks
Dmitry



0
Comment actions Permalink

Not exactly what you're after, but try CTRL-` in the
editor to quickly switch


thanks. this is helpful.

if you do that don't most of your problems go away
(apart from #2)?


not really, as what I want to do is to work in my own style and have files persisted in a different style. I could switch between styles as you have suggested, but then I'd have to (remember to) switch and reformat before every save and SCM commit. On top of that, running diffs against SCM would also be cumbersome. In the diff case, I guess what I'd prefer to do is an option of doing a structural diff (a la structural search).

0
Comment actions Permalink

not really, as what I want to do is to work in my own
style and have files persisted in a different style.
I could switch between styles as you have suggested,
but then I'd have to (remember to) switch and
reformat before every save and SCM commit. On top
of that, running diffs against SCM would also be
cumbersome. In the diff case, I guess what I'd
prefer to do is an option of doing a structural diff
(a la structural search).


Is this the feature you want?
http://www.jetbrains.net/jira/browse/IDEABKL-1043
Unfortunately it is languishing in the backlog...too bad as it would be a sweet feature that would distinguish IDEA from the pack. You can always vote for it.

0
Comment actions Permalink

That (Multiple code styles for cvs checkout and commit) is a very tall order, I think. It implies considerable bookkeeping about the edits applied vis. a vis. the "essential" form in the source-code repository.

I've long thought that program "source" should be stored as an AST of some sort. Every author who works on that code will see it formatted in their preferred manner. When checking in changes, the differences are those based on the AST, not on the sequence of characters as seen by any given programmer.

]]>

Randall Schulz

0

Please sign in to leave a comment.