Home  >  Article  >  Development Tools  >  How vscode formats code

How vscode formats code

(*-*)浩
(*-*)浩Original
2019-11-08 13:55:5112812browse

How vscode formats code

The shortcut keys for formatting code with vs code are as follows:

On Windows Shift Alt F (recommended learning: vscode introductory tutorial)

Shift Option F

on Mac, Ctrl Shift I

on Ubuntu, but the built-in formatting does not meet my needs. This Sometimes, I have to say that plug-ins are good.

Code formatting to eslint style

Requires plugin: eslint

How vscode formats codeAdd in settings:

"eslint.autoFixOnSave": true,
"eslint.validate": [
  "javascript",
  "javascriptreact",
  {
    "language": "html",
    "autoFix": true
  },
  {
    "language": "vue",
    "autoFix": true
  }
],

eslint.autoFixOnSave is used to automatically format when saving, but only supports javascript .js files by default.

eslint.validate is used to configure the file type used.

Then when you save the code, it will be automatically formatted into eslint style (it needs to be saved multiple times).

The above is the detailed content of How vscode formats code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn