简体   繁体   English

Visual Studio C#自动缩进选择

[英]Visual Studio c# auto indent selection

I would like to perform auto indentation on my c# code in visual studio, however the (Ctrl K,D) option reports "The key combination (Ctrl K,D) is not a command". 我想在Visual Studio中对我的C#代码执行自动缩进,但是(Ctrl K,D)选项报告“组合键(Ctrl K,D)不是命令”。

I try Ctrl K, Ctrl D but this also has no effect. 我尝试按Ctrl K,按Ctrl D,但这也没有任何效果。

Even when I select Edit->Advanced->Format Selection, this has no effect. 即使选择“编辑”->“高级”->“格式选择”,这也无效。

Update : 更新:

It appears that for code such as 似乎对于诸如

XElement element1 = new XElement("books",
    books.Select(x => new XElement("book",
       new XElement("name", x.Name),
       new XElement("price", x.Price))));

The format selection or format document commands have no effect, however these commands work for more 'regular' constructs. 格式选择或格式文档命令无效,但是这些命令适用于更多“常规”结构。

您可以尝试进入“工具”->“选项”->“环境”->“键盘”,然后在顶部找到“应用以下其他键盘映射方案:”,如果还没有,请选择Visual C#2005。

In the menu: Edit/Advanced has some formatting commands. 在菜单中:编辑/高级具有一些格式命令。 You should see their associated shortcuts as well. 您还应该看到它们相关的快捷方式。

For me it shows: 对我来说,它表明:

  • Ctrl + E, D - format document Ctrl + E,D-格式化文档
  • Ctrl + K, Ctrl + F - format selection Ctrl + K,Ctrl + F-格式选择

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM