在使用Visual Studio代码时,如何自定义制表符到空格的转换因子?
例如,现在在HTML中,每次按TAB键会产生两个空格,但在TypeScript中会产生4个空格。
在使用Visual Studio代码时,如何自定义制表符到空格的转换因子?
例如,现在在HTML中,每次按TAB键会产生两个空格,但在TypeScript中会产生4个空格。
当前回答
在Visual Studio Code版本1.31.1或更高版本中(我认为):像sed Alex Dima一样,您可以通过这些设置轻松地自定义
Windows菜单中的文件→首选项→用户设置或使用短键Ctrl + Shift + P Mac在菜单代码→首选项→设置或⌘,
其他回答
我不得不像之前的答案一样做了很多设置编辑,所以我不知道在做了很多修改后它能正常工作。
在我关闭并打开我的IDE之前没有任何工作,但我所做的最后三件事是禁用lonefy。html.format vscode-js-css-html-formatter。”enable": true,并重新启动Visual Studio。
{
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"workbench.colorTheme": "Default Light+",
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features",
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.insertSpaces": true
},
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
"editor.tabSize": 2,
"typescript.format.insertSpaceAfterConstructor": true,
"files.autoSave": "afterDelay",
"html.format.indentHandlebars": true,
"html.format.indentInnerHtml": true,
"html.format.enable": true,
"editor.detectIndentation": false,
"editor.insertSpaces": true,
}
在你的右下角,有空格: 空间:2
在这里你可以根据你的需要改变缩进: 缩进的选项
默认情况下,Visual Studio Code自动检测当前打开文件的缩进。如果您想关闭此功能并使所有缩进,例如,两个空格,您可以在用户设置或工作区设置中执行以下操作。
{
"editor.tabSize": 2,
"editor.detectIndentation": false
}
那是孤独。要怪vcode -js-css-html-formatter。禁用它,并安装HookyQR.beautify。
现在保存你的标签不会被转换。
我们亲爱的社区成员已经提供了很多很好的答案。我实际上想添加c#代码tabSize,并找到了这个线程。我找到了很多解决方案,官方VS Code文档很棒。我只是想分享我的c#设置:
"[csharp]": {
"editor.insertSpaces": true,
"editor.tabSize": 4
},
只需复制并粘贴上述代码到您的设置。Json文件并保存。谢谢