VS 代码的 EditorConfig 不起作用
EditorConfig for VS Code not working
我使用 VS Code 作为编辑器。我们有一个 .editorconfig
文件,其中包含格式配置。我们都在我们的编辑器中使用扩展 EditorConfig 来格式化我们的 HTML 和 CSS 常规。我已经从这里安装了 VS Code 的扩展 EditorConfig:https://github.com/editorconfig/editorconfig-vscode
我们的 .editorconfig 文件如下所示:
# This is the top-most .editorconfig file (do not search in parent directories)
root = true
### All files
[*]
# Force charset utf-8
charset = utf-8
# Indentation
indent_style = tab
indent_size = 4
# line breaks and whitespace
insert_final_newline = true
trim_trailing_whitespace = true
# end_of_line = lf
### Frontend files
[*.{css,scss,less,js,json,ts,sass,php,html,hbs,mustache,phtml,html.twig}]
### Markdown
[*.md]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false
### YAML
[*.yml]
indent_style = space
indent_size = 2
### Specific files
[{package,bower}.json]
indent_style = space
indent_size = 2
我找不到任何键盘快捷键、设置或其他。如何让我的扩展执行 .editorconfig
文件中的操作?
我自己的解决方案:
我遇到的问题是,我将扩展名 editorconfig
添加到我的 vscode
,但没有为其安装 npm package
。所以仅仅将扩展添加到您的 vscode 是不够的,您还必须安装软件包,所以它可以 运行.
我这样安装 npm package
全局的:npm install -g editorconfig
之后我添加了扩展并启用了它。现在完美了。
这是所需 npm 包的 link:https://www.npmjs.com/package/editorconfig
这是您的 vscode 所需扩展的 link:https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
此外,我还需要打开“保存时编辑器格式”选项。
{
"editor.formatOnSave": true
}
我收到错误“Extension EditorConfig cannot format ...”(在 IDE 的底部,几秒钟后消失)。
更改首选项(ctrl+,
,搜索 format
并将 Editor:DefaultFormatter
设置为 None
(而不是 EditorConfig
))解决了以下问题我(是的,有趣的是,这确实启用了 .editorconfig
的使用 - 而不是任何其他格式规则)
Codium:1.60.2 与 EditorConfig:v0.16.6
我使用 VS Code 作为编辑器。我们有一个 .editorconfig
文件,其中包含格式配置。我们都在我们的编辑器中使用扩展 EditorConfig 来格式化我们的 HTML 和 CSS 常规。我已经从这里安装了 VS Code 的扩展 EditorConfig:https://github.com/editorconfig/editorconfig-vscode
我们的 .editorconfig 文件如下所示:
# This is the top-most .editorconfig file (do not search in parent directories)
root = true
### All files
[*]
# Force charset utf-8
charset = utf-8
# Indentation
indent_style = tab
indent_size = 4
# line breaks and whitespace
insert_final_newline = true
trim_trailing_whitespace = true
# end_of_line = lf
### Frontend files
[*.{css,scss,less,js,json,ts,sass,php,html,hbs,mustache,phtml,html.twig}]
### Markdown
[*.md]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false
### YAML
[*.yml]
indent_style = space
indent_size = 2
### Specific files
[{package,bower}.json]
indent_style = space
indent_size = 2
我找不到任何键盘快捷键、设置或其他。如何让我的扩展执行 .editorconfig
文件中的操作?
我自己的解决方案:
我遇到的问题是,我将扩展名 editorconfig
添加到我的 vscode
,但没有为其安装 npm package
。所以仅仅将扩展添加到您的 vscode 是不够的,您还必须安装软件包,所以它可以 运行.
我这样安装 npm package
全局的:npm install -g editorconfig
之后我添加了扩展并启用了它。现在完美了。
这是所需 npm 包的 link:https://www.npmjs.com/package/editorconfig
这是您的 vscode 所需扩展的 link:https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
此外,我还需要打开“保存时编辑器格式”选项。
{
"editor.formatOnSave": true
}
我收到错误“Extension EditorConfig cannot format ...”(在 IDE 的底部,几秒钟后消失)。
更改首选项(ctrl+,
,搜索 format
并将 Editor:DefaultFormatter
设置为 None
(而不是 EditorConfig
))解决了以下问题我(是的,有趣的是,这确实启用了 .editorconfig
的使用 - 而不是任何其他格式规则)
Codium:1.60.2 与 EditorConfig:v0.16.6