C# Visual Studio 改变 Ctrl-KD 的工作方式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15281099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 16:16:03  来源:igfitidea点击:

Visual Studio changing the way Ctrl-K-D works

c#javascriptvb.netvisual-studioformatting

提问by Mark Pieszak - Trilon.io

In Visual Studio (I'm using 2012), is there any way of editing the way that Ctrl-K-Dcombinations handles its Auto-Formatting?

在Visual Studio(我使用的是2012),有编辑的方式,任何方式Ctrl- K-D组合处理其自动格式化

I don't mean changing what these key combinations do, I mean extending the way the auto-formatting is done.

我的意思不是改变这些组合键的作用,我的意思是扩展自动格式化的方式

The way it handles tabbing, etc are fine, I'm more concerned with white-space.

它处理tabbing等的方式很好,我更关心white-space

We're using a plugin that makes it easy to align variable properties, making them easy to read. Like so:

我们正在使用一个插件,可以轻松对齐变量属性,使其易于阅读。像这样:

var test            = 'whatever',
    another         = 'this one',
    alignedProperly = 'yay';

Seems nitt-picky yes, but in really large Object literals it's so helpful to be able to read them!

看起来很挑剔是的,但是在非常大的对象文字中,能够阅读它们非常有帮助!

Has anyone found where the rules for auto-formatting are located, and if they can be edited/changed?(Can't find them anywhere in the options!)

有没有人找到自动格式化规则的位置,是否可以编辑/更改?(在选项中的任何地方都找不到它们!)

采纳答案by publicgk

Are you looking for:

您是否正在寻找:

Tools > Options > Text Editor > C# > Formatting > Spacing > Set other spacing options > Ignore space in declaration statements

工具 > 选项 > 文本编辑器 > C# > 格式 > 间距 > 设置其他间距选项 > 忽略声明语句中的空格

This is in VS 2010, but i guess 2012 should be somewhat similar.

这是在 VS 2010 中,但我想 2012 应该有点相似。

回答by Cirelli94

In VS 2017:

在 VS 2017 中:

Tools > Options > Text Editor > C# > Code Style > Formatting > Spacing > Set other spacing options > Ignore space in declaration statements

工具 > 选项 > 文本编辑器 > C# > 代码样式 > 格式 > 间距 > 设置其他间距选项 > 忽略声明语句中的空格