简体   繁体   中英

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".

I try Ctrl K, Ctrl D but this also has no effect.

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 + K, Ctrl + F - format selection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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