本文介绍了如何在Visual Studio 2015中禁用所有空白自动格式设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢新的Visual Studio 2015,但是自动格式化对我来说有点太广泛了.特别是我喜欢控制空格:

I really like the new Visual Studio 2015, but the auto formatting is a bit too much extensive for my liking. Especially I like to have control over whitespace:

public class TipStats
{
    public int      Points          { get; set; }
    public int      Position        { get; set; }
    public decimal  Percentage      { get; set; }
}

我在设置中仅看到三个自动套用格式设置,并且已将它们全部打勾-Visual Studio仍在自动格式化我的空格.

I only see three autoformat settings in my settings, and I have ticked them all off - still Visual Studio is autoformatting my whitespace.

要禁用所有空白自动格式化,是否还需要了解其他隐藏设置?

Are there any other hidden settings that I need to know for disabling all whitespace autoformatting?

更新正如@Saragis所指出的,对于此特定示例,忽略声明语句中的空格有时有时是有效的,但是仍然有各种各样的自动格式化强制我想要的东西工作.

UpdateAs @Saragis notes Ignore spaces in declaration statements works sometimes for this specific example, but still there all kind of autoformat forces working against what I want.

大多数选项似乎仅定义方式您要进行自动格式化的方式.我正在寻找定义如果您要自动格式化的设置.

Most options seem to only define how you want your autoformatting. I'm looking for the setting that defines if you want autoformatting.

PS:我在自动格式化时仅遇到问题,我仍然使用 CTRL + K,F 来手动格式化部分代码然后.

PS: I'm having only problems with autoformatting I still use CTRL+K, F to manual format parts of my code now and then.

更新-在UserVoice上添加了功能请求

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/9795837-add-an-ignore-space-for-all-format-options

推荐答案

我意识到我在原始答案中误解了这个问题,因此添加了部分答案,禁止对空格进行自动格式化.
如果在提供的所有选项上选择ignore white space,它将不会重新格式化这些代码区域的空白.

I realised I misunderstood the question in my original answer, so have added a partial answer disabling autoformatting for white space.
If you select ignore white space on all options where it is offered, it will not reformat the white space of those areas of code.

这些屏幕截图来自VS2015 Enterprise.
我从一开始就帮助任何在这里着陆的人.

These screen shots are taken from VS2015 Enterprise.
I'm starting from the beginning to help anyone who lands here.

转到工具->选项.

向下滚动到文本编辑器".值得点击所有常规标签.以及所有语言标签.可以设置一些共享的格式设置,例如自动换行.

Scroll down to Text Editor. It's worth clicking through the all the general tabs. And the All languages tabs. There are some shared formatting settings that can be set, like line wraps.

然后转到您要自定义的语言(我在显示C#),然后单击格式.在那里,您会找到选项,根据您的问题的标题,我已经将间距扩大了一个.

Then go to the languages you wish to customise (I'm showing C#) and click on formatting. There you will find options, I have expanded the spacing one, as per the title of your question.

然后,您可以浏览这些选项卡中的每个选项卡,以自定义每种语言的格式.

Then you can explore each of these tabs to customise your format for each language.

编辑-由于问题实际上已更改

要减少自动格式化的发生,请取消选中以下选项:

To reduce the incidents of autoformatting, uncheck options like these:

管理自动格式设置的唯一方法是使用这些设置.您也可以将regex与find和replace一起使用,以从文件中删除空间,但是要小心.除了这些技巧之外,我还能想到的一切就是自定义自动格式化,减少VS自动格式化的过程以及手动进行自动格式化.

The only way you can manage the autoformatting is to play with these settings.You can also use regex with find and replace to remove space from files, but do so carefully.Beyond these tips to customise your autoformatting, to reduce VS process of autoformatting and to manually autoformat, that's all I can think of.

还有这个:在编辑"->高级"->删除水平空白"下

There is also this:Under Edit -> Advanced -> Delete Horizontal White Space

这篇关于如何在Visual Studio 2015中禁用所有空白自动格式设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:34