Search code examples
formattingvisual-studio-code

How to change indentation in Visual Studio Code?


For every typescript file visual studio code uses an auto indentation of 8 spaces. This is a bit too much for my taste but I can't find where to change it.

Maybe it's available as a setting but under a different name as I can't find anything related to indentation.

UPDATE

I'm currently using the Prettier code formatter and that solves all formatting problems by auto formatting on save (if there is no syntax error)


Solution

  • You can change this in global User level (all your projects if not deliberately set) or Workspace level (only for the current working project).

    Open the settings: Click the gear on the bottom left, then click Settings as shown below.

    Settings on VS Code menu

    Then, do the following 2 changes: (type tabSize in the search bar)

    1. Uncheck the checkbox of Detect Indentation
    2. Change the tab size to be 2/4 (Although I strongly think 2 is correct for JS. Haha :))

    vscode set tabsize