Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditorConfig for VS Code not working

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?

like image 545
webta.st.ic Avatar asked Oct 20 '17 09:10

webta.st.ic


People also ask

Where is the EditorConfig Vscode?

Note: some settings can only be applied on file save, as indicated above. A new . editorconfig file can be created via the Explorer sidebar's context menu by right-clicking in the folder where you'd like it to be and selecting Generate . editorconfig .

What is EditorConfig in angular?

The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.


2 Answers

In addition all of the above I also needed to turn on the Editor Format on Save option.

{    "editor.formatOnSave": true } 
like image 23
Jordon Davidson Avatar answered Sep 24 '22 12:09

Jordon Davidson


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

like image 133
webta.st.ic Avatar answered Sep 23 '22 12:09

webta.st.ic