To indent a line of code one level, press Ctrl + ].
To unindent a line of code one level, press Ctrl + [.
To indent multiple lines of code, select the lines of code and then press
Ctrl + ] or Ctrl + [.
2. Using the Command Palette
To open the Command Palette, press Ctrl + Shift + P.
Type "indent" and then select the "Indent Lines" command.
In the dialog box that appears, select the number of spaces you want to indent the lines by.
3. Changing the settings
You can also change the default indentation settings in Visual Studio Code. To do this, open the Settings editor by pressing
Ctrl + ,. In the settings editor, search for the "editor.tabSize" and "editor.insertSpaces" settings. The "editor.tabSize" setting controls the number of spaces that are inserted when you press the Tab key. The "editor.insertSpaces" setting controls whether Visual Studio Code should insert spaces or tabs when you indent code.
For example, to change the indentation to 4 spaces, you would set the "editor.tabSize" setting to 4. To change Visual Studio Code to use spaces instead of tabs, you would set the "editor.insertSpaces" setting to true.
Here are the steps on how to change the indentation in Visual Studio Code using the settings:
Open the Visual Studio Code app.
Open the code file you want to change the indentation for.
Press Ctrl + , to open the Settings editor.
In the Settings editor, search for the "editor.tabSize" setting.
In the "editor.tabSize" setting, enter the number of spaces you want to use for indentation.
Save your changes.
Once you have saved your changes, the indentation in your code file will be changed to the number of spaces you specified.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
There are a few ways to change indentation in Visual Studio Code.
1. Using the keyboard shortcuts
2. Using the Command Palette
3. Changing the settings
You can also change the default indentation settings in Visual Studio Code. To do this, open the Settings editor by pressing Ctrl + ,. In the settings editor, search for the "editor.tabSize" and "editor.insertSpaces" settings. The "editor.tabSize" setting controls the number of spaces that are inserted when you press the Tab key. The "editor.insertSpaces" setting controls whether Visual Studio Code should insert spaces or tabs when you indent code.
For example, to change the indentation to 4 spaces, you would set the "editor.tabSize" setting to 4. To change Visual Studio Code to use spaces instead of tabs, you would set the "editor.insertSpaces" setting to true.
Here are the steps on how to change the indentation in Visual Studio Code using the settings:
Once you have saved your changes, the indentation in your code file will be changed to the number of spaces you specified.