首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VS代码的EditorConfig不起作用

VS代码的EditorConfig不起作用
EN

Stack Overflow用户
提问于 2017-10-20 17:25:49
回答 3查看 21.1K关注 0票数 49

我使用VS Code作为编辑器。我们有一个带有格式配置的.editorconfig文件。我们都在我们的编辑器中使用扩展EditorConfig来格式化我们的HTML和CSS。我已经从这里安装了VS代码的扩展EditorConfig:https://github.com/editorconfig/editorconfig-vscode

我们的.editorconfig文件如下所示:

代码语言:javascript
复制
# 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文件中做这些事情?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 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

票数 67
EN

Stack Overflow用户

发布于 2021-01-17 00:09:20

除此之外,我还需要打开保存时的编辑器格式选项。

代码语言:javascript
复制
{
   "editor.formatOnSave": true
}
票数 3
EN

Stack Overflow用户

发布于 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46846128

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档