CodeSource code example

How to fix Vscode indentation


Indentation in vs code is used to format your code. In this tutorial, you are going to learn how to fix indentation in Vscode.

The code formatting is available in Visual Studio Code through the following shortcuts:

On Windows: Shift + Alt + F

On Mac: Shift + Option + F

On Linux: Ctrl + Shift + I

Alternatively, you can find the shortcut, as well as other shortcuts, through the ‘Command Palette’ provided in the editor with Ctrl +Shift+ P (or Command + Shift + P on Mac), and then search for format document. On windows-

fix Vscode indentation

You can format the code in vscode using the tabs and using the spaces. To do that, vscode shows the indentation settings of your current file in the status bar at the bottom. Like this-

If you click on the Tab Size, this will show-

If you want indentation using tabs, just click on it and specify the number of tabs.

fix Vscode indentation

By default, it is configured to 4 means each tab is being treated as four characters wide.

You can do the same for using the indentation using spaces.

The other way to convert indentations manually is, to click into the status bar again and you can use two options. Convert Indentation to Spaces and Convert Indentation to Tabs.

fix Vscode indentation

This will convert your indentation directly. So, these are the ways, you can fix indentation in vscode.


Share on social media

//