问题描述
我正在使用VS Code编辑多种语言(主要是Ruby,PHP和Javascript)的项目,对于每种语言,我们都有不同的缩进模型(空格/制表符和宽度).看起来VS Code支持此功能,因为它允许将editor.insertSpaces
和editor.tabSize
都设置为"auto"
,这是每个语言的定义.
I'm using VS Code to edit projects in multiple languages (mostly Ruby, PHP and Javascript) and for each language we have different indentation models (spaces/tabs and width). Looks like VS Code supports this as it allows both editor.insertSpaces
and editor.tabSize
to be set to "auto"
which is a per-language definition.
但是,尽管editor.tabSize
看起来可以满足我的需求,但editor.insertSpaces
始终在"auto"
模式下插入空格.
But while editor.tabSize
looks to do about what I want, editor.insertSpaces
always insert spaces when in "auto"
mode.
我试图找到可以在其中编辑每种语言配置的位置,但没有找到这种设置.我还查看了resources/app/client/vs/languages
下的语言目录,但是没有找到指定这些功能的内容.
I've tried to find where one can edit the per-language configuration but have found no such setting. I've also looked in the language directories under resources/app/client/vs/languages
but have failed to find something that specifies these features.
有什么想法如何自定义每种语言的设置?
Any idea how to customize the per-language settings?
推荐答案
要使用语言设置,请在方括号中使用[language_id]
:
To use perlanguage settings, you use the [language_id]
in square brackets:
示例:
{
"[typescript]": {
"editor.formatOnSave": true,
"editor.formatOnPaste": true
},
"[markdown]": {
"editor.formatOnSave": true,
"editor.wrappingColumn": 0,
"editor.renderWhitespace": "all",
"editor.acceptSuggestionOnEnter": false
}
}
更新:版本 1.10
这篇关于如何更改设置"editor.insertSpaces"的每个语言的配置.到“自动"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!