user2526586
user2526586

Reputation: 1200

Setting tab-space style in Visual Studio Code... accordingly to the project type

How can I set the tab-to-space indentation conversion in VSCode? For instance, when I press the Tab key, I want it to produce 4 spaces.

BUT WAIT before you jump to the answer straight away... I know this kind of config questions has probably been asked many times here, but I want to ask this question slightly differently here. Please bear with me.

I know there is a "guess" option somewhere in config of VSCode, but instead of having VSCode to "guess" per file, I want to set it such that when I am doing Python-related projects, it will produce 4 spaces... but when I am doing other projects with VSCode - files like HTML, JavaScript, PHP, XML, etc, I want it to produce normal tabs.

Is that possible? Since I switch to different kind of projects a lot, I just don't want to switch/modify config files all the time.

Upvotes: 1

Views: 275

Answers (1)

Chukwuemeka Inya
Chukwuemeka Inya

Reputation: 2671

Go to File > Preferences > Settings. User Settings should pop up. Add the following:

    "editor.detectIndentation": false,
    "[python]": {
        "editor.tabSize": 4
    },
    "[html]": {
        "editor.tabSize": 2
    },

Upvotes: 3

Related Questions