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?
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 .
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.
In addition all of the above I also needed to turn on the Editor Format on Save option.
{ "editor.formatOnSave": true }
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With