在我的项目中,我有TypeScript和HTML文件,在这两个文件中,选项卡都转换为空格。
我想关闭自动转换,并确保我的项目只有选项卡。
编辑:
通过这个设置,它似乎可以在HTML文件中工作,但不能在TypeScript文件中工作。
{
"editor.insertSpaces": false
}
在我的项目中,我有TypeScript和HTML文件,在这两个文件中,选项卡都转换为空格。
我想关闭自动转换,并确保我的项目只有选项卡。
编辑:
通过这个设置,它似乎可以在HTML文件中工作,但不能在TypeScript文件中工作。
{
"editor.insertSpaces": false
}
当前回答
文件->首选项->设置或只需按Ctrl +,并搜索空格,然后只需禁用此选项:
我必须重新打开文件,这样更改才能生效。
其他回答
下面的设置对我来说很好,
"editor.insertSpaces": false,
"editor.formatOnSave": true, // only if you want auto fomattting on saving the file
"editor.detectIndentation": false
上述设置将反映并应用于每个文件。你不需要手动缩进/格式化每个文件。
要更改选项卡设置,单击vscode窗口右下方状态栏中的Ln/Col文本右侧的文本区域。
名称可以是“Tab Size”或“Spaces”。
一个菜单将弹出所有可用的操作和设置。
从官方的vscode设置中检查:
// Controls whether `editor.tabSize#` and `#editor.insertSpaces` will be automatically detected when a file is opened based on the file contents.
"editor.detectIndentation": true,
// The number of spaces a tab is equal to. This setting is overridden based on the file contents when `editor.detectIndentation` is on.
"editor.tabSize": 4,
// Config the editor that making the "space" instead of "tab"
"editor.insertSpaces": true,
// Configure editor settings to be overridden for [html] language.
"[html]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": false
}
文件->首选项->设置或只需按Ctrl +,并搜索空格,然后只需禁用此选项:
我必须重新打开文件,这样更改才能生效。
如果你正在使用.sass文件,它会给你预期的制表符,是空格错误,将此设置为false:
"editor.detectIndentation": false
…然后选择你的代码块,按TAB键缩进,按shift + TAB键缩进。