Vscode format configuration

Time:2020-12-3

1、 Install common plug-ins:

CTRL + Shift + X open the store to search for these plug-ins to install

Beautify、Eslint、Vetur

2 setting.josn to configure

File preferences settings in setting.josn Open this setting.josn After the file, copy the following configuration

{
    //The tab size is 2 spaces
    "editor.tabSize": 2,
    //Wrap after 100 columns
    "editor.wordWrapColumn": 100,
    //Format on save
    "editor.formatOnSave": true,
    //Open vscode file path navigation
    "breadcrumbs.enabled": true,
    //Prettier sets the end of the statement without semicolon
    "prettier.semi": false,
    //Prettier sets the mandatory single quotation mark
    "prettier.singleQuote": true,
    //Select the format tool of template in Vue file
    "vetur.format.defaultFormatter.html": "prettyhtml",
    //Display the special characters generated when switching between Chinese and English in markdown
    "editor.renderControlCharacters": true,
    //Set eslint to auto repair when saving
    "eslint.autoFixOnSave": true,
    //Eslint detects the file type
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        {
            "language": "html",
            "autoFix": true
        },
        {
            "language": "vue",
            "autoFix": true
        }
    ],
    //Custom settings of vertur
    "vetur.format.defaultFormatterOptions": {
        "prettier": {
            "singleQuote": true,
            "semi": false
        }
    },
    //Automatically save after 500ms modification
    "editor.formatOnSaveTimeout": 500,
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 500,
    "editor.codeActionsOnSaveTimeout": 500,
    "[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    }
}

3、 Configure. Editorconfig file

Find the. Editorconfig file in the root directory of the project, and then copy the following configuration

# https://editorconfig.org
For the configuration file of root = true, the editor will look up from the current directory. If a file with 'roor = true' is found, it will not be searched again

[*] ා match all files
indent_ Style = space ා space indent
indent_ Size = 4 ා indent 4 spaces
end_ Of_ Line = LF ා the file newline character is Linux 'ා n`
Charset = UTF-8 ᦇ the file code is UTF-8
trim_ trailing_ Whitespace = true ා do not reserve spaces at the end of a line
insert_ final_ Newline = true ා add a blank line at the end of the file
curly_ bracket_ next_ Line = false ා braces do not start a new line
spaces_ around_ Operators = true ා the operator has spaces twice
indent_ brace_ Style = 1TBS ා the conditional statement format is 1TBS

[*. JS] ා takes effect on all JS files
quote_ Type = single ා string using single quotation marks

[*. {HTML, less, CSS, JSON}] # takes effect on all HTML, less, CSS, JSON files
quote_ Type = double ා string uses double quotation marks

[ package.json ]Yes package.json  take effect
indent_ Size = 2 ා indent with 2 spaces

The notes are all written, so I won’t be wordy any more. It’s really dry goods. Try it!

Recommended Today

PHP 12th week function learning record

sha1() effect sha1()Function to evaluate the value of a stringSHA-1Hash. usage sha1(string,raw) case <?php $str = “Hello”; echo sha1($str); ?> result f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 sha1_file() effect sha1_file()Function calculation fileSHA-1Hash. usage sha1_file(file,raw) case <?php $filename = “test.txt”; $sha1file = sha1_file($filename); echo $sha1file; ?> result aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d similar_text() effect similar_text()Function to calculate the similarity between two strings. usage similar_text(string1,string2,percent) case […]