Is there a format code shortcut for Visual Studio?

前端 未结 9 774
梦谈多话
梦谈多话 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:27

    Try Ctrl + K + D (don't lift the Ctrl key in between).

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

    To align the text in the proper format -

    • Ctrl + K + D for front end pages like .aspx or .cshtml

    • Ctrl + K + F for a .cs page

    But observe to press all buttons in sequence...

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

    Select all text in the document and press Ctrl + E + D.

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

    Ctrl + K + D (Entire document)

    Ctrl + K + F (Selection only)

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

    Yes, you can use the two-chord hotkey (Ctrl+K, Ctrl+F if you're using the General profile) to format your selection.

    Other formatting options are under menu EditAdvanced, and like all Visual Studio commands, you can set your own hotkey via menu ToolsOptionsEnvironmentKeyboard (the format selection command is called Edit.FormatSelection).

    Formatting doesn't do anything with blank lines, but it will indent your code according to some rules that are usually slightly off from what you probably want.

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

    Format the entire document:

    Ctrl + K + D

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