我的项目中同时有 TypeScript 和 HTML 文件,在这两个文件中,选项卡都转换为空格。
我想关闭自动转换并确保我的项目只有标签。
编辑:
使用此设置,它似乎适用于 HTML 文件,但不适用于 TypeScript 文件。
{
"editor.insertSpaces": false
}
最佳答案
.vscode/settings.json
中有3个选项:
// The number of spaces a tab is equal to.
"editor.tabSize": 4,
// Insert spaces when pressing Tab.
"editor.insertSpaces": true,
// When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
"editor.detectIndentation": true
editor.detectIndentation
从您的文件中检测到它,您必须禁用它。
如果没有帮助,请检查您是否没有具有更高优先级的设置。
例如,当您将其保存到用户设置时,它可能会被项目文件夹中的工作区设置覆盖。
更新:
要访问这些设置,您可以打开文件 » 首选项 » 设置,点击管理齿轮图标在左下角,或使用键盘快捷键:
CTRL+, (Windows、Linux)
⌘+, (Mac)
更新:
现在您可以选择手动编辑这些选项。
点击编辑器右下角的选择器Spaces:4:
编辑:
要将现有缩进从空格转换为制表符,请点击 Ctrl+Shift +P 并输入:
>Convert indentation to Tabs
这将根据定义的设置将文档的缩进更改为制表符。
关于visual-studio-code - Visual Studio Code - 将空格转换为制表符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36814642/