How to enable auto indent in VS Code

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

  1. From the top-level “File” menu, select Preferences. From the sub-menu, choose Settings. Alternatively, you can just press Ctrl + ,

    Open Settings.

  2. In the search bar, type “indent”.

    Search Indent
    Type “indent” In the search bar.

  3. Choose the option full from the “Editor: Auto Indent” drop-down.

    Choose full from the “Editor: Auto Indent” drop-down.

  4. Auto-indentation is now enabled. VS Code will now automatically indent code when you typepaste 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.

Leave a Comment