What the hell is EditorConfig?
Editorconfig is something that helps developers define and maintain code styles (line terminators, indentation styles, etc.).
What rules does EditorConfig support?
Please refer to editorconfig.org/
How to use editorconfig in vscode?
- Add the. Editorconfig file in the current project root directory
- Install the EditorConfig extension. What? Open the baidu or Google, input vscode installation extension | vscode install the extension; Ok, no more hints)
- Global or local installation editorconfig rely on package (NPM install – g editorconfig | NPM install – D editorconfig)
- Open files that need formatting and manually format the code (Shift + Alt + F)
Briefly explain what each step does:
- The first step in the editorconfig file is to define some formatting rules (which are not parsed directly by vscode)
- The second EditorConfig extension reads the rules defined in the EditorConfig file created in the first step, And override the corresponding Settings in user/workspace Settings.
- Step 3: Install editorConfig dependencies mainly because EditorConfig depends on the EditorConfig package. If you do not install editorConfig, editorConfig will not be able to parse the EditorConfig file we defined in step 1
- Step 4 is to enable the User /workspace Settings overridden by the EditorConfig extension
Problems you might encounter
- When user/workspace setting in the files. TrimTrailingWhitespace = true trim_trailing_whitespace = false won’t take effect
- Eol: “files.eol”: “\n”
Note: Terminator requires CTRL + S for the current file to take effect (other rules take effect when formatting code by pressing Shift + Alt + F)