What's the difference between “editor.insertSpaces” and “editor.tabSize” in settings?

时光毁灭记忆、已成空白 提交于 2021-01-27 04:41:40

问题


How are they interpreted differently? I can only see what "editor.tabSize" does, which is the number of spaces that a tab occupies.

Thank you.


回答1:


From the configuration file:

{
  // 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
}

As you can see editor.tabSize sets the size of space occupied when you enter tab. While editor.insertSpaces configures the stored key code in file.

If editor.insertSpaces equals false then Visual Studio Code will insert one #09 character for each tab. When you change editor.tabSize your existing code will change indentation in all lines a #09 character is stored.

If editor.insertSpaces equals true then Visual Studio Code will insert space characters for each tab instead of #09 characters. The amount of inserted spaces is configured in editor.tabSize. When you change editor.tabSize your existing code will not change indentation since there is no #09 character being stored in the file. Only new tab strokes will be affected by the new value of editor.tabSize.

If you and other team members use only tab for indentation then it is no problem to set editor.insertSpaces to false. If you and other team members use space or tab for indentation then you should set editor.insertSpaces to true. Otherwise your files can look awkward when somebody opens a file with a different value of editor.insertSpaces.




回答2:


editor.insertSpaces: Controls if the editor will insert spaces for tabs. Accepted values: "auto", true, false. If set to "auto", the value will be guessed when a file is opened.

editor.tabSize: Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened.



来源:https://stackoverflow.com/questions/32720854/whats-the-difference-between-editor-insertspaces-and-editor-tabsize-in-sett

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!