Ryan Griggs
Ryan Griggs

Reputation: 2758

How can I configure all new files to use tab indention instead of spaces by default?

Currently, whenever I create a new file (no matter the file type) it starts out using spaces for indention. I always have to click and convert to tabs.

How can I configure all new files to use tabs by default to avoid this step?

Upvotes: 1

Views: 564

Answers (1)

starball
starball

Reputation: 50234

Put the following in whichever settings file makes sense for you (your user settings.json, or a .vscode/settings.json, or a .code-workspace file):

"editor.insertSpaces": false

You can change this setting on a per-file-type basis like so:

"[json]": {"editor.insertSpaces": true},
"[javascript]": {"editor.insertSpaces": false}

To change the indentation for an existing file, use the Convert Indentation to Tabs command.

You can also use editor.detectIndentation to change whether VS Code should try to detect what indentation a file is already using to follow it.

Upvotes: 2

Related Questions