EditorConfig for VS Code not working

webta.st.ic picture webta.st.ic · Oct 20, 2017 · Viewed 18.6k times · Source

I use VS Code as editor. We have a .editorconfig file with format configs within. We all use in our editors the extenion EditorConfig to format our HTML and CSS general. I have installed the extension EditorConfig for VS Code from here: https://github.com/editorconfig/editorconfig-vscode

Our .editorconfig file looks like this:

# 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

I can't find any keyboard shortcut, setting or else. How to get my extension do the stuff from the .editorconfig file?

Answer

webta.st.ic picture webta.st.ic · Jan 30, 2018

MY OWN SOLUTION:

The problem I had was, that I added the extension editorconfig to my vscode, but didn't install the npm package for it. So it's not enough, to add the extension only to your vscode, you have also to install the package, so it could run.

I installed the npm package global like this: npm install -g editorconfig

After that I added the extension and enabled it. Now it works perfect.

Here is the link to the required npm package: https://www.npmjs.com/package/editorconfig

Here is the link to the required extenion for your vscode: https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig