skip to Main Content

VS Code provides an action panel to change the indentation settings

enter image description here

I change it from Spaces: 2 to Spaces: 4. However, when I click on a different file, it goes back to Spaces: 2, forcing me to manually go through every file in my codebase an click the setting.

I would expect there to be a way to apply this system-wide. Is there?

2

Answers


  1. Chosen as BEST ANSWER

    1. Press F1 > Preferences: Open Settings (UI)

    enter image description here

    2. Set Editor.tabSize to desired value

    enter image description here

    3. Disable Editor.detectIndentation

    enter image description here


  2. Put the following in your settings.json file:

    "editor.tabSize": 4
    

    The setting’s description:

    The number of spaces a tab is equal to. This setting is overridden based on the file contents when #editor.detectIndentation# is on.


    You may also find it useful to add the following:

    "editor.detectIndentation": false
    

    The setting’s description:

    Controls whether #editor.tabSize# and #editor.insertSpaces# will be automatically detected when a file is opened based on the file contents.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search