views:

101

answers:

3

This is not a subjective nor an argumentative question but a question that needs a yes/no answer and, if the answer is positive, the name(s) of said editor(s).

Imagine the company guideline mandates committed code to use the K&R style and that I prefer Allman (for example). Are there editors (either standalone or part of an IDE) that allow you to always "view" your source code using the Allman style, yet always save the file using the K&R style?

It doesn't seem that far-fetched nor that complicated: the source code/text file would always be saved using the "official" style, but what the editor would show you on-screen wouldn't be exactly your text file but a "view" of your text file using the indent style of your choice. And hence every developer would be free to choose the indent style he/she preferred.

Does an editor (either standalone or integrated with an IDE) that does this exist?

Note that I'm really asking if there exist editor(s) that do this, not if there are workflows allowing one to do something similar (for example suggesting to me to use GNU indent before doing my Mercurial hg commit is not anywhere near an answer to the question).

A: 

No.    

Aleks
I shortened it for you.
SLaks
+1  A: 

Vim allows you to specify exactly how you want it's indenting to work. Check out:

http://vimdoc.sourceforge.net/htmldoc/indent.html#cinoptions-values

Once it is specified, re-indent the whole document with:

1G=G

Then all you need is to write a macro to set indent style, re-indent and save and another one that autoloads the correct indent style when opening a file.

slebetman
You'll need an extra layer of logic no insure that you can save an unmodified file without `q!`. Similar trick could be played in emacs.
dmckee
A: 

Visual Age for Java had a similar feature: Its internal SCM stored the content of your Java sources in a non-text format that kept all the information that's important for the compiler. Each developer could decide how exactly he'd like to view the Java sources.

This included viewing methods/fields without the surrounding class and also the ability to use any code layout you'd like (including custom ones).

This page explains how to write a custom formatter. Unfortunately I couldn't find any screenshots of this feature in action.

Joachim Sauer