This is the third day of my participation in Gwen Challenge
Articles written before, continue to share.
As the name implies, EditorConfig is an editor configuration that helps developers define and maintain consistent encoding styles across different editors and ides. It consists of a file format for defining encoding styles and a set of text editor plug-ins that enable the editor to read file formats and follow the defined styles. The EditorConfig file is easy to read and works with the version control system.
. Editorconfig sample
The following is an example of a. Editorconfig file that styles line endings and indentation for Python and Javascript files.
# EditorConfig is awesome: https://EditorConfig.org # top-most EditorConfig file root = true # Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true # Matches multiple files with brace expansion notation # Set default charset [*.{js,py}] charset = utf-8 # 4 space indentation [*.py] indent_style = space indent_size = 4 # Tab indentation (no size specified) [Makefile] indent_style = tab # Indentation override for all JS under lib directory [lib/**.js] indent_style = space indent_size = 2 # Matches the exact files either package.json or .travis.yml [{package.json,.travis.yml}] indent_style = space indent_size = 2Copy the code
When a file is opened with the IDE, the EditorConfig plug-in looks for the.EditorConfig file in the directory where the file was opened and its parent nodes at each level until it finds one with root = true configured.
File Format Details
The EditorConfig file uses INI format. A slash (/) is used as a path separator, # or; As a note. Paths support wildcards:
The wildcard | instructions |
---|---|
* | Matches any character except / |
支那 | Matching any string |
? | Matches any single character |
[name] | Match the name character |
[!name] | Does not match the name character |
[s1,s2,s3] | Matches the given string |
[num1..num2] | Matches straight integers from num1 to mun2 |
EditorConfig supports the following properties:
attribute | instructions |
---|---|
indent_style | Indent using TAB or space |
indent_size | The number of characters indented when the indent is space |
tab_width | The width of the indent when it is TAB |
end_of_line | The type of a newline character. Lf, CR, CRLF three kinds |
charset | File charset. The following types are available: LATin1, UTF-8, UTF-8-BOM, UTF-16BE, utF-16LE |
trim_trailing_whitespace | Whether to delete the trailing space automatically |
insert_final_newline | Whether to end the file with a blank line |
root | Editorconfig: indicates the top-level configuration file. If true is set, search for. Editorconfig file will stop |
Supported editors and ides
No need to install plug-ins
These editors come bundled with native support for EditorConfig.
Need to install plug-ins
To use EditorConfig with one of the editors, you need to install a plug-in.
To use EditorConfig with one of the headless tools, you also need to install a plug-in.
Summary: What problems can be solved?
- Fixed an issue where markdown files automatically delete end-of-line Spaces
# http://editorconfig.org
root = true
[*]
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
Copy the code
- Solve github code presentation or team development project format inconsistency (sometimes my local code format on Github format will be messy, which is quite useful)
# editorconfig.org
root = true
[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Copy the code
More and more
Wiki: github.com/editorconfi…