How do you auto format code in Visual Studio?

To format a selection: Ctrl+KCtrl+F

To format a document: Ctrl+KCtrl+D

See the pre-defined keyboard shortcuts. (These two are Edit.FormatSelection and Edit.FormatDocument.)

Note for macOS

On macOS, use the CMD ⌘ key instead of Ctrl:

  • To format a selection: CMD ⌘+KCMD ⌘+F
  • To format a document: CMD ⌘+KCMD ⌘+D

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)