Mat*_*yev 106 tabs spaces typescript visual-studio-code
我写作TypeScript和HTML文件,标签变成了空格.这是我第一次使用Visual Studio Code.
我试图更改设置并重新启动,但没有任何改变.
我配置的设置:
{
"editor.insertSpaces": false
}
Run Code Online (Sandbox Code Playgroud)
我想谷歌它,我发现我做了正确的一步,当我加入TypeScript到.html,但它不改变我的喜好...
编辑1:
我发现标签工作在.ts文件中,但不是TypeScript文件...
v-a*_*rew 184
有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
Run Code Online (Sandbox Code Playgroud)
.vscode/settings.json从您的文件中检测到它,您必须禁用它.如果没有帮助,请检查您没有更高优先级的设置.例如,当您将其保存到用户设置时,它可能会被项目文件夹中的工作区设置覆盖.
更新:
现在您可以手动编辑这些选项.
单击编辑器右下角的选择器Spaces:4:
如果要将现有ws转换为制表符,请从Marketplace安装扩展程序
编辑:
要将现有缩进从空格转换为标签命中editor.detectIndentation和键入:
>Convert indentation to Tabs
Run Code Online (Sandbox Code Playgroud)
这将根据Tabs的已定义设置更改文档的缩进.
Eri*_*sot 122
要更改选项卡设置,请单击vscode窗口右下方状态栏中Ln/Col文本右侧的文本区域.
名称可以是Tab Size或Spaces.
将弹出一个菜单,其中包含所有可用的操作和设置.
Ale*_*vin 11
File?Preferences?Settings或按Ctrl + ,editor.insertSpacesF1?输入reload window?按Enter)可能是因为安装了JS-CSS-HTML Formatter插件
(你可以去检查File?Preferences?Extensions或只是按Ctrl + Shift + X,在启用名单,你会发现JS-CSS-HTML格式化)
如果是这样,您可以修改此插件:
Formatter config?按Enter(它将打开文件formatter.json) 4| "indent_size": 1,
5| "indent_char": "\t"
——|
24| "indent_size": 1,
25| "indentCharacter": "\t",
26| "indent_char": "\t",
——|
34| "indent_size": 1,
35| "indent_char": "\t",
36| "indent_character": "\t"
Run Code Online (Sandbox Code Playgroud)
File?Save或按Ctrl + S)reload window?按Enter)以下设置对我来说效果很好,
"editor.insertSpaces": false,
"editor.formatOnSave": true, // only if you want auto fomattting on saving the file
"editor.detectIndentation": false
Run Code Online (Sandbox Code Playgroud)
以上设置将反映并应用于每个文件.您无需手动缩进/格式化每个文件.
从官方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,
// Configure editor settings to be overridden for [html] language.
"[html]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": false
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
123407 次 |
| 最近记录: |