如何在 Visual Studio 2015 中禁用所有空格自动格式化? [英] How to disable all whitespace autoformatting in Visual Studio 2015?

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

问题描述

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

公共类TipStats{公共整数点{得到;放;}公共 int 位置 { 得到;放;}公共小数百分比{得到;放;}}

我在我的设置中只看到三个自动格式化设置,我已经全部勾选了 - Visual Studio 仍在自动格式化我的空格.

为了禁用所有空白自动格式化,我还需要了解其他任何隐藏设置吗?

更新正如@Saragis 指出的那样,忽略声明语句中的空格有时适用于这个特定示例,但仍然存在各种自动格式强制与我想要的相反.

大多数选项似乎只定义了如何自动格式化.我正在寻找定义如果您想要自动格式化的设置.

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

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

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

转到工具 -> 选项.

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

然后转到您希望自定义的语言(我展示的是 C#)并单击格式.在那里你会找到选项,我已经根据你的问题标题扩大了间距.

然后,您可以浏览这些标签中的每一个,以针对每种语言自定义格式.

编辑-因为问题实际上已经改变

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

管理自动格式化的唯一方法是使用这些设置.您还可以使用带有查找和替换的正则表达式从文件中删除空间,但要小心操作.除了这些自定义自动格式化、减少 VS 自动格式化和手动自动格式化的过程之外,我能想到的就是这些.

<小时>

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

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; }
}

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?

Update As @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: I'm having only problems with autoformatting I still use CTRL+K, F to manual format parts of my code now and then.

Update - Added feature request on UserVoice

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

解决方案

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.

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

Go to Tools -> Options.

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.

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.

edit- since question has actually changed

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

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 中禁用所有空格自动格式化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆