A brief discussion on the method of formatting vscode code

青灯夜游
Release: 2021-01-04 17:24:43
forward
30719 people have browsed it

A brief discussion on the method of formatting vscode code

Related recommendations: "vscode tutorial"

The shortcut keys for formatting code in vs code are as follows: (from here)

  • On WindowsShiftAltF
  • On MacShiftOptionF
  • On UbuntuCtrlShiftI

But the built-in formatting does not It cannot meet my needs. At this time, I have to say that the plug-in method is good.

1. The code is formatted in eslint style (reference from here)

Requires plug-in: eslint


in settings Add to:

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

eslint.autoFixOnSaveis used to automatically format when saving, but only supportsjavascript .jsfiles by default.

eslint.validateUsed 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).

2. HTML formatting code indentation

Requires plug-in: Vetur


Vetur is a very powerful plug-in , provides powerful support for writing Vue code with vs code, and alsosupports most mainstream front-end development scripts. For details, you can see here ->Vetur Document

After installing this plug-in, you can see the following content in the settings:


##In order to make HTML code can be formatted and indented by adding the following:

"vetur.format.defaultFormatter.html": "prettier"
Copy after login
and then using the shortcut keys for formatting code.

For more programming-related knowledge, please visit:

Programming Courses! !

The above is the detailed content of A brief discussion on the method of formatting vscode code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!