如何在vscode中更改tabSize和insertSpaces

时间:2015-05-08 14:17:33

标签: whitespace indentation visual-studio-code

你如何实际更改vscode的“editor.tabSize”和“editor.insertSpaces”值?我打开了文件>偏好>用户设置并添加:

// Place your settings in this file to overwrite the default settings
{
// Controls the rendering size of tabs in characters. If set to auto, the value will be guessed based on the opened file.
"editor.tabSize": 4,

// Controls if the editor will insert spaces for tabs. If set to auto, the value will be guessed based on the opened file.
"editor.insertSpaces": true,
}

但是,当我打开带有两个空格标签的html文件时,按Tab键会插入两个空格,当我打开一个使用\ t标签的文件时,按Tab键插入\ t。

我做错了什么导致vscode不尊重我的设置?

1 个答案:

答案 0 :(得分:6)

您的代码段中有一个尾随逗号,目前VSCode无法理解格式错误的JSON设置。我很高兴地说,在下次更新时,应该修复此问题:)!

设置的工作版本是:



// Place your settings in this file to overwrite the default settings
{
// Controls the rendering size of tabs in characters. If set to auto, the value will be guessed based on the opened file.
"editor.tabSize": 4,

// Controls if the editor will insert spaces for tabs. If set to auto, the value will be guessed based on the opened file.
"editor.insertSpaces": true
}