1. What is editorconfig?
example
As the name suggests, EditorConfig is an editor configuration that helps developers define and maintain consistent coding styles between different editors and IDEs. It consists of a file format for defining coding styles and a set of text editor plug -ins that enable editing The compiler is able to read the file format and follow the defined style. EditorConfig files are easy to read and work well with version control systems.
2. What problem was solved
The purpose is to solve the different styles between different editors and different operating systems. This is to take effect when writing code
3. How to integrate editorcofig
Create a new file under the root directory of our project called .editorconfig
Take webstorm as an example, we directly create it and it will read this file by itself
Take vscode as an example, we need to download the plug-in called editorconfig for vs code to take effect
# https://editorconfig.org
root = true
[*] //表示所有的文件都可用
charset = utf-8 //设置文件的字符集
indent_style = space //缩进的风格是space 回车键
indent_size = 2//缩进大小是2
end_of_line = lf //缩进类型视lf
insert_final_newline = true //始终再文章末尾进入一个新行
trim_trailing_whitespace = true //移除无效空格
[*.md] //表示md文档只需要尊行以下规则
insert_final_newline = false
trim_trailing_whitespace = false