设置中的“editor.insertSpaces”和“editor.tabSize”有什么区别?

suh*_*eti 7 visual-studio-code

他们如何不同地解释?我只能看到“editor.tabSize”的作用,即制表符占用的空格数。

谢谢你。

Wos*_*osi 8

从配置文件:

{
  // 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
}
Run Code Online (Sandbox Code Playgroud)

如您所见,editor.tabSize设置了输入时占用的空间大小tab。同时editor.insertSpaces配置文件中存储的密钥代码。

如果editor.insertSpaces等于,false则 Visual Studio Code 将为#09每个tab. 当您更改editor.tabSize现有代码时,更改所有行中的缩进,#09并存储一个 字符。

如果editor.insertSpaces等于,true则 Visual Studio Code 将为space每个字符tab而不是#09字符插入字符。插入的数量在spaces中配置editor.tabSize。更改editor.tabSize现有代码时不会更改缩进,因为#09文件中没有存储字符。只有新tab笔画会受到新值的影响editor.tabSize

如果您和其他团队成员 tab用于缩进,那么设置editor.insertSpaces为 false没有问题。如果您和其他团队成员使用space tab缩进,那么您应该设置editor.insertSpaces为 true。否则,当有人打开具有不同值的文件时,您的文件可能看起来很尴尬editor.insertSpaces