问题描述
对于每个打字稿文件,Visual Studio代码都使用8个空格的自动缩进.这对我来说有点太多了,但是我找不到更改它的地方.
For every typescript file visual studio code uses an auto indentation of 8 spaces. This is a bit too much for my taste but I can't find where to change it.
也许它可以作为设置使用,但使用其他名称,因为我找不到与缩进有关的任何东西.
Maybe it's available as a setting but under a different name as I can't find anything related to indentation.
更新
我目前正在使用更高级的代码格式化程序,它可以解决通过保存时自动格式化来解决所有格式化问题(如果没有语法错误)
I'm currently using the Prettier code formatter and that solves all formatting problems by auto formatting on save (if there is no syntax error)
推荐答案
您可以在全局User
级别或Workspace
级别进行更改.
You can change this in global User
level or Workspace
level.
打开设置:使用快捷键 或单击File
> Preferences
> Settings
如下所示.
Open the settings: Using the shortcut or clicking File
> Preferences
> Settings
as shown below.
然后,进行以下两项更改:(在搜索栏中键入tabSize
)
Then, do the following 2 changes: (type tabSize
in the search bar)
- 取消选中
Detect Indentation
的复选框 - 将制表符大小更改为2/4(尽管我强烈认为2对JS是正确的:))
- Uncheck the checkbox of
Detect Indentation
- Change the tab size to be 2/4 (Although I strongly think 2 is correct for JS :))
这篇关于如何在Visual Studio Code中更改缩进?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!