Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
606 views
in Technique[技术] by (71.8m points)

c# - How do I turn off Visual Studio's formatting options?

So I have this annoying issue with Visual Studio (when working with C#), I've been digging around in the C# formatting options, general VS options and on google and MSDN but can't really find a fix for this - I'm assuming there's just a checkbox somewhere and I've just overlooked it. Here it is:

I like to format my code like this:

Type var2    = new Type();
Type someVar = new Type();

But visual studio insists on formatting it like this, whenever the automatic format feature is applied:

Type var2 = new Type();
Type someVar = new Type();

Where do I turn this annoying feature off?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In the Formatting Options, In the Spacing section:

there is an option called 'Ignore spaces in declaration statements'. Check that option, and VS.NET will not re-format the declarations that you make.

So, this should work:

int i      = 5;
int melp   = 4;

But, when you do this, VS.NET will still reformat your code:

int i;
int melp;

i    = 5;
melp = 4;

will become:

int i;
int melp;

i = 5;
melp = 4;

So, it is really only in declaration statements that VS.NET will ignore the extra spacing you provide.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...