Home Dashboard Directory Help
Search

Virtual custom indentation settings by 011AD87E-7821-48F8-9E70-FD1A6BBE3C9A


Status: 

Closed
 as Won't Fix Help for as Won't Fix


0
0
Sign in
to vote
Type: Suggestion
ID: 241726
Opened: 11/29/2006 7:02:45 PM
Access Restriction: Public
0
Workaround(s)
view

Description

It is often the case that different developers on the same project have conflicting choices in terms on indentation styles. The typical solution is to standardize on one indentation formatting, so that all the code is indented in a uniform manner. The downside of this approach is that, inevitably, some developers will be forced to use uncomfortable / undesirable indentation settings. I have a proposed solution for this problem that I would like to see implemented in a future version of Visual Studio. I suppose you could call it "virtual indentation" or something like that. Here is how it might work:

There are two indentation settings, one for the file written on the disk, and one for the indentation displayed to the developer in the IDE. Indentation of new and existing code displayed in the editor window conforms to the developer's IDE settings, regardless of the representation on disk. When the changes are written back to the file, the disk settings are used, and the file written out will conform to the disk settings.

Example #1:
Say I personally prefer a certain style of indention (block indentation, I suppose), exemplified by this snippet (example 1a):

if(variable == true)
    {
    my_function();
    }

And the project requirements dictate that the following indentation style is used for the same snippet (example 1b):

if(variable == true) {
    my_function();
}

Using this method, I could write code indented in my style (as exemplified in 1a), and have the version on disk be that which is required by the project (as exemplified in 1b). Additionally, when viewing code in the project's format (1b), the editor would automatically format it (superficially (just in the editor view), of course, not making any changes to the actual file) to suit my indentation preferences (1a). The result is that the developer with a conflicting style of the project is not inconvenienced by the choice of indentation style for the project, and the indentation of the project stays consistent.

The complexity of such a feature is fairly involved, I would think. The biggest issue that I would foresee would be the difference in line numbers on the "virtual" indentation style versus the real style that is fed into the compiler and written to the disk. This can be mitigated, however, in a similar manner than line wrapping (or word wrap) uses: the actual line spans multiple lines in the editor, with a visual arrow indicator on the right hand side of the text edit control. Another potential problem would be when different styles have conflicting stances on curly-brace usage for, say, one-line control structures. This is more minor, and can be ignored without it impacting the "feel" of the indentation style.



Side issue: why are the formatting options so rich in C#, but so limited in C/C++? I would think that it would be trivial to extend the formatting options that exist in C# to C and C++, and it would be necessary for this feature request to work properly.
Details
Sign in to post a comment.
Posted by Microsoft on 1/8/2007 at 11:10 AM
Phreak,

Thank you for your suggestion.

We will not be able to implement it in the version of Visual Studio currently under development, but we will consider it for the next.

Thanks!
-Brad Peterson
Visual Studio Editor Test Lead
Sign in to post a workaround.