我使用VS Code作为编辑器。我们有一个带有格式配置的.editorconfig文件。我们都在我们的编辑器中使用扩展EditorConfig来格式化我们的HTML和CSS。我已经从这里安装了VS代码的扩展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文件中做这些事情?
发布于 2018-01-30 22:07:54
我自己的解决方案:
我遇到的问题是,我在vscode中添加了扩展editorconfig,但没有为它安装npm package。因此,仅将扩展添加到您的vscode中是不够的,您还必须安装软件包,以便它可以运行。
我像这样安装了npm package全局文件:npm install -g editorconfig
之后,我添加了扩展并启用了它。现在,它完美地工作了。
以下是所需npm包的链接:https://www.npmjs.com/package/editorconfig
下面是您的vscode所需扩展的链接:https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
发布于 2021-01-17 00:09:20
除此之外,我还需要打开保存时的编辑器格式选项。
{
"editor.formatOnSave": true
}发布于 2021-10-01 14:37:49
我收到错误消息"Extension EditorConfig cannot format ...“(在IDE的底部,几秒钟后消失)。
更改首选项(ctrl+,、搜索format并将Editor:DefaultFormatter设置为None (而不是EditorConfig))为我解决了这个问题(是的,有趣的是,这确实启用了.editorconfig --而不是任何其他格式规则)
Codium: 1.60.2,EditorConfig: v0.16.6
https://stackoverflow.com/questions/46846128
复制相似问题