Editorconfig Plugin - What’s it for?

Asked

Viewed 127 times

2

I accessed the official website of the plugin Editorconfig, I’m not very good in English so I tried to translate to read and it didn’t work very well, so I didn’t understand very well the functionality of it, so I would like to know:

  • What’s he good for?
  • How is used?
  • What advantages do I gain by using it?

2 answers

3


It serves to define the editing patterns of your project. A great example of this is how 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 decide to edit your project in a friend’s home, and their editor inserts 6 space characters.

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 break in the pattern when editing at your friend’s house. In order to make this standardization that serves editorconfig, you define the editing properties that you used, and in any editor that you open your project, we will have the same behavior.

1

What good is he?
Editorconfig helps developers define and maintain consistent coding styles between different editors and Ides. This means that no matter which editor you use, you and your team just use the plugin to make the code consistent.

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

I leave here the settings 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 to set file defaults.

A very simple example of these patterns would be: align code using spaces or tabs. Only this pattern already generates a 01 month discussion among 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 if you change only one line of the code, whenever one of them submits this file to the code versioner, all the other lines will be changed as well, because their code alignment configuration is different.

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

Completion

Even being a very old topic, I wrote a very interesting article about Editorconfig and I would like to share with you.

Here is the link to the article:
https://showmethecode.com.br/2017/03/29/editor-config/

In the article I approach:

  • What is Editorconfig?
  • Why to use Editorconfig?
  • Editorconfig in VS Code
  • Using the Editorconfig
  • 1

    We appreciate your willingness to collaborate with the community, but it might be interesting to read the text We want answers that contain only links? The main problem is that if the answer link eventually ceases to exist, the answer completely loses its meaning. To get around this, check with the content of the link the main points that are valid to the question and describe them here, keeping the link only as a support material.

  • @Andersoncarloswoss I believe the answer is much better now. Thanks for the feedback.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.