我该如何关闭Visual Studio的格式选项?我该、选项、格式、Studio

2023-09-02 02:03:01 作者:丿glorious灬永恒

所以我有这个与Visual Studio(使用C#工作时)恼人的问题,我一直在周围挖在C#格式化选项,一般VS选择和谷歌和MSDN,但不能真正找到这个修复 - 我假设这里只有一个复选框地方,我只是忽略了它。在这里,它是:

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:

我想格式化我的code是这样的:

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();

我在哪里可以把这个烦人的功能的关闭?

推荐答案

在格式化选项,在间距部分:

In the Formatting Options, In the Spacing section:

有一个名为忽略的声明语句空间选项。 检查选项,VS.NET不会重新格式化您所做的声明。

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.

所以,这应该工作:

int i      = 5;
int melp   = 4;

但是,当你做到这一点,VS.NET仍然会重新格式化您的code:

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

int i;
int melp;

i    = 5;
melp = 4;

将变成:

int i;
int melp;

i = 5;
melp = 4;

所以,这确实是只有在声明语句VS.NET会忽略你提供额外的间距。

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

 
精彩推荐
图片推荐