'What is the shortcut to auto indent code in VSCode?

I work with both C++ and Python, however ctrl+k f doesn't seem to auto-indent my code. Is there anything I might be missing?

If I need to install an extension that is OK, but I would prefer to use a built in method if there is one.



Solution 1:[1]

  1. Press Ctrl+Shift+P to open Command Palette. Type in settings and select Open User Settings.

  2. In Search settings box, input indent to search for settings related to indentation. Select full in Editor: Auto Indent section.

  3. Automatic indentation is now enabled. Changes are saved automatically and applies to all opened files as well.

But its better to install plugins like linter or formatter or beautifier so you can use commands like Shift + Alt + F to format your code

Solution 2:[2]

I am wondering the same thing and find this native solution.

On Windows Shift + Alt + F
On Mac Shift + Option + F
On Ubuntu Ctrl + Shift + I

Ref: https://www.codegrepper.com/code-examples/whatever/how+to+auto+indent+in+visual+studio+code

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Walulya francis
Solution 2 ACCL