What is the shortcut to auto indent code in VSCode?

Viewed 30538

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.

3 Answers
  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

if you go into Options > C/C++ > Code Style > General > When I paste, the first option is "Indent and format".

so if you select all, cut, then paste, it should auto indent everything for you. probably not the fanciest or most robust answer but it works for me.

Related