Visual Studio code formatting
Asked Answered
A

3

12

I've been using Visual Studio as my main IDE for a while now (I still use Emacs for some personal projects, though).

I like the way Emacs formats C/C++ code and I'd like to convince Visual Studio use similar conventions for C# code. For instance, in Emacs, a C function call looks like:

functionName(argument1,
             argument2,
             argument3);

while in the C# code formatted by Visual Studio a function call looks like:

functionName(argument1,
    argument2,
    argument3);

which seems worse to me.

Is there a way to tweak Visual Studio code formatting rules? Any plugins that can handle that?

Many thanks,

Ajit answered 14/11, 2008 at 7:51 Comment(0)
W
20

Tools > Options > Text Editor > C# > Formatting

and

http://www.jetbrains.com/resharper/features/code_formatting.html#Code_Formatting

Wherry answered 14/11, 2008 at 7:53 Comment(4)
Thanks, but while that allows many customizations, I can't see a way to solve the problem in my example. It's just a minor nuissance, though.Ajit
You could also drop the first argument to the next line which would make all arguments align.Wherry
Thanks for the suggestion, that's what I do sometimes, but it 'wastes' a line. However I'm a bit annoyed because I consider the Emacs default formatting better (I bet I would feel the other way around if I had used Visual Studio before Emacs :-) )Ajit
One man's 'waste' is another man's clear code. Sorry I don't have other ideas except maybe writing a VS macro for this particular bugbear.Wherry
B
7

Resharper (above) is good. CodeRush is now free from DevExpress. I've enjoyed using their products over the years.

http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/

Biegel answered 14/11, 2008 at 9:23 Comment(0)
S
0

See also this extension that will automate the process each time a file is saved : https://visualstudiogallery.msdn.microsoft.com/3ea1c920-69c4-441f-9979-ccc2752dac56

Schoolfellow answered 17/10, 2014 at 21:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.