html - VS 代码的 EditorConfig 不起作用

标签 html css visual-studio-code editorconfig

我使用 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 包 .所以仅仅将扩展添加到你的 vscode 是不够的,你还必须安装包,这样它才能运行。

我像这样全局安装了 npm 包:npm install -g editorconfig

之后我添加了扩展并启用了它。现在它完美地工作了。

所需的 npm 包:https://www.npmjs.com/package/editorconfig

所需的 vscode 扩展:https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig

关于html - VS 代码的 EditorConfig 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46846128/

相关文章:

json - vscode package.json 字符串与模式不匹配

javascript - Div 激活时页面重定向

javascript - WebWorks 应用程序根本无法运行,但可以在 Ripple 和 Chrome 以及 BB 浏览器中运行

css - 如何使 div 垂直但与水平 div 的左下坐标对齐?

python - 使用 Visual Studio Code 在 Python 中逐步调试导入的模块

visual-studio-code - 如何重置 Visual Studio Code 中的设置?

html - wrapper 下的两个 div 跟随 wrapper div 的 margin-top 值,它不应该

html - <nav> 带图片的列表

asp.net - 容器中显示的图像 - 如何缩小和保持纵横比

jquery - 图像 slider 中的元素符号导航