Navigate this page
hide
Indenting makes code more structured and easy to read. It helps us keep code tidy to help with workflow. There are two methods to automatically indent code in Visual Studio Code. By default, auto indent is disabled on Visual Studio Code. This guide shows you how to enable auto-indentation for code in Visual Studio Code.
Method #1: Enable auto-indent in Settings
- From the top-level “File” menu, select Preferences. From the sub-menu, choose Settings. Alternatively, you can just press Ctrl + ,
- In the search bar, type “indent”.
- Choose the option full from the “Editor: Auto Indent” drop-down.
- Auto-indentation is now enabled. VS Code will now automatically indent code when you type, paste or move your code.
Methods #2: Enable auto-indent on Save
Visual Studio Code has built-in support for automatic formatting (including indentation) upon saving the document. We have written a guide on enabling VS Code auto-formatting here.