Is there a format code shortcut for Visual Studio?

前端 未结 9 775
梦谈多话
梦谈多话 2020-11-30 15:45

In Eclipse there is a shortcut, Ctrl+Shift+F, that re-indents code and fixes comments and blank lines. Is there an equivalent for Visual Stu

相关标签:
9条回答
  • 2020-11-30 16:37

    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 to format the entire document.

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

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

    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 (Entire document)

    Ctrl + K + F (Selection only)

    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.


    (Please do not edit this answer to change the key bindings above to what your system has!)

    0 讨论(0)
  • 2020-11-30 16:42

    Right click on the code, and you have "Format Document". In my case it is Ctrl+Shift+I

    0 讨论(0)
  • 2020-11-30 16:43

    ReSharper - Ctrl + Alt + F

    Visual Studio 2010 - Ctrl + K, Ctrl + D

    0 讨论(0)
提交回复
热议问题