Plugin EditorConfig - What's the use?

2

I went to the official site of the EditorConfig plugin , I'm not very good at English so I tried translating to read and it did not work, so I did not understand much well the functionality of it, then I would like to know:

  • What is it for?
  • How is it used?
  • What advantages do I gain by using it?
asked by anonymous 10.04.2016 / 16:58

2 answers

3

It serves to set the editing standards for your project. A great example of this is the way your code is indentation. Let's illustrate with a case where you use an editor that inserts 4 characters to indent the code. You then resolve to edit your project in a friend's house, and the publisher inserts 6 characters of space.

Your code would look something like:

//parte feita na sua casa:
function codigoFeitoNoSeuEditor(){
    console.log("Fiz isso na minha casa maluca.");
}

//parte feita na casa do seu amigo:
function codigoFeitoNoEditorDoMeuAmigo(){
        console.log('Fiz isso na casa do meu amigo alienígena');
}

As you can see, there was a default break when editing at your friend's house. In order to do this standardization that editorconfig serves, you define the editing properties you used, and in any editor you open your project, we will have the same behavior.

    
10.04.2016 / 17:45
1

What is it good for?
EditorConfig helps developers define and maintain consistent encoding styles between different publishers and IDEs. This means that no matter which editor you use, you and your team simply use the plugin to make the code consistent.

How is it used?
On the official website in the Downloads section you can download the plugin for various code editors. The first step is to download and install the plugin. To use the plugin, just create a .editorconfig file at the root of your project and adjust the settings according to your preference.

I leave here the settings that I use in almost all my projects.

root = true

[*]
   charset = utf-8
   end_of_line = lf
   indent_size = 2
   indent_style = space
   insert_final_newline = true
   trim_trailing_whitespace = true

[* .md]
   max_line_length = off
   trim_trailing_whitespace = false

What advantages do I gain by using it?
Developers choose to use different code editors, and each of these editors has its own settings for setting file patterns.

A very simple example of these patterns would be: align code using spaces or tabs . Only this pattern already generates a discussion of 01 month between developers of the same project.

Imagine a developer who likes to use 04 spaces to align his code and another who likes to use 02 tabs. Even changing one line of the code, whenever one of them submits this file to the code versioner, all other lines will change as well, since their code alignment configuration is different.

To solve this and other problems, someone had the brilliant idea to develop a plugin for most code editors.

Conclusion

Although it is a very old topic, I wrote a very interesting article about EditorConfig and would like to share it with you.

Here is the link to the article:
link

In the article I board:

  • What is EditorConfig?
  • Why use EditorConfig?
  • EditorConfig in VS Code
  • Using EditorConfig
26.04.2017 / 01:00