且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Visual Studio 是否有格式代码快捷方式?

更新时间:2023-01-31 11:15:31

Visual Studio with C# 键绑定

要回答具体问题,在 C# 中,您可能会使用 C# 键盘映射方案,默认情况下将使用这些热键:

Visual Studio with C# key bindings

To answer the specific question, in C# you are likely to be using the C# keyboard mapping scheme, which will use these hotkeys by default:

Ctrl+E, Ctrl+D 格式化整个文档.

Ctrl+E, Ctrl+D to format the entire document.

Ctrl+E, Ctrl+F 格式化选择.

Ctrl+E, Ctrl+F to format the selection.

您可以在菜单 ToolsOptionsEnvironmentKeyboard(通过选择不同的键盘映射方案",或将单个键绑定到命令Edit.FormatDocument"和Edit.FormatSelection").

You can change these in menu ToolsOptionsEnvironmentKeyboard (either by selecting a different "keyboard mapping scheme", or binding individual keys to the commands "Edit.FormatDocument" and "Edit.FormatSelection").

如果您没有选择使用 C# 键盘映射方案,那么您可能会发现快捷键不同.例如,如果您不使用 C# 绑定,则键可能是:

If you have not chosen to use the C# keyboard mapping scheme, then you may find the key shortcuts are different. For example, if you are not using the C# bindings, the keys are likely to be:

Ctrl + K + D(整个文档)

Ctrl + K + D (Entire document)

Ctrl + K + F(仅限选择)

Ctrl + K + F (Selection only)

要找出哪些键绑定适用于您的 Visual Studio 副本,请查看菜单编辑高级菜单 - 显示了键位于菜单项的右侧,因此很容易发现它们在您的系统上的内容.

To find out which key bindings apply in your copy of Visual Studio, look in menu EditAdvanced menu - the keys are displayed to the right of the menu items, so it's easy to discover what they are on your system.

(请不要编辑此答案以将上面的键绑定更改为您的系统所拥有的!)