

Enabling this requires configuring the setting 'editor.formatOnSave': true. Formatting the source code as and when you save the contents of the file is supported. The default code format provider is autopep8. Code formatting is supported using either one of yapf or autopep8.But.if you want to add the Format Document button to a tool bar do this: Right click on tool bar. In Visual Studio 2017 and Visual Studio 2019 Format Document is Ctrl + E, D.Indentation, New Lines, Spacing Wrapping pages. You can also specify to run it only for manually invoked formatting commands Format Document (Ctrl+K, Ctrl+D) or Format Selection (Ctrl + K, Ctrl + F). By default, Visual Studio runs clangformat.exe in the background applies formatting as you type. In Options dialog select Environment-Keyboard form the tree and set your own shortcuts for Edit.FormatDocument. Dialog (select Tools-Options from the menu).

Use Ctrl + K + Ctrl + D to format document keystroke Use Ctrl + K + Ctrl + F to format selection keystroke It's also possible to set your own keystrokes by opening Options.
