Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Why) would I use both an .editorconfig file and the VS code workspace settings in a project?

Assuming I am only using VS Code as the editor, is there an advantage to include a .editorconfig file in a project if I already have workspace settings saved. Or, a disadvantage: such as .editorconfig potentially overwrite my VS Code settings or vice-versa?

like image 493
Brandon Avatar asked Dec 22 '18 14:12

Brandon


2 Answers

TL;DR;

Basically, .editorconfig has advantages when:

  • you're working in a team

or

  • a way to preserve your settings so you can easily use them in other projects in case you lose your existing IDE settings (eg. customise stuff in your IDE but then format your computer)

More info

the .editorconfig file is usually committed into the code repo so it can be used by multiple people working on the same repo. This enables you to have code consistency across all team members. You might like using tabs but the rules are set to use spaces. Sorry, team rules override your personal rules. Consistency wins.

VSCode workspace settings (or any built in IDE workspace settings) can be individually configured (per person) and thus could be different and make the files in the repository, inconsistent. You might use tabs while other people use spaces and it messes things up for everyone because now you're all fighting on coding style(s).

.editorconfig files might require a 3rd part extension to work with your IDE (which is the case with VSCode) while IDE workspace settings are baked in to the IDE (no extra download(s) required). NOTE: Visual Studio (as opposed to VSCode) has this baked in.

IDE's usually allow you to 'backup' your IDE settings ... so it's true you can backup your settings and use them later on.

Not everyone in a team always uses the same IDE's. Again, means nothing if you're just working solo on something.

like image 128
Pure.Krome Avatar answered Nov 15 '22 08:11

Pure.Krome


First off .editorconfig only works in VSCode using a plugin. The advantage for .editorconfig is that other editors also recognize it. The advantage for VSCode workspace settings is that it doesn't require a plugin and can include more settings.

From what I can tell .editorconfig takes precedence over user and workspace settings. Although I couldn't find an official statement on this (but also one hint is that they mention this not being true for one of the settings as a bug).

I would use .editorconfig for what I can and include VSCode workspace config for the remaining settings. I'd avoid conflicting settings.

like image 36
thisismydesign Avatar answered Nov 15 '22 08:11

thisismydesign