Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to format vue files automatically when saving in vscode

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to automatically format vue files in vscode when they are saved. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

1. Install the plug-in

Vscode installs the following plug-ins:

Eslint

Vetur

Prettier-Code formatter

Format 2.vue files when they are saved

Hold down commond+shift+p and search for perferences open setting (json).

Add the following to the configuration file, be careful not to copy it all directly, it may overwrite your own configuration. It is recommended that you copy it in and remove the duplicate key.

{"editor.suggestSelection": "first", "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", "explorer.confirmDelete": false, "editor.tabSize": 2, "files.autoSave": "onFocusChange", "editor.fontSize": 14, / / set the font "editor.tabCompletion": "on", / / when the recommended value appears Press the Tab key whether to automatically fill in the best recommended value "editor.codeActionsOnSave": {"source.fixAll.eslint": true, "source.organizeImports": true / / this attribute can automatically adjust the related order of import statements when saving. Enable your import statements to be arranged alphabetically}, "editor.formatOnSave": true,// # let the js in vue be formatted in "prettier" format "vetur.format.defaultFormatter.html": "js-beautify-html", "vetur.format.defaultFormatter.js": "prettier-eslint", "vetur.format.defaultFormatterOptions": {"js-beautify-html": {/ / # html code formatting style "wrap_attributes": "auto" in the vue component / / can also be set to "auto" The effect will be different "wrap_line_length": 200," end_with_newline ": false," semi ": false," singleQuote ": true}," prettier ": {" semi ": false," singleQuote ": true," editor.tabSize ": 2}," prettyhtml ": {" printWidth ": 160," singleQuote": false, "wrapAttributes": false, "sortAttributes": false}}, "[vue]": {"editor.defaultFormatter": "octref.vetur"}, "bracketPairColorizer.depreciation-notice": false "editor.mouseWheelZoom": true} problem record

Format all files in the directory

Download the plug-in Start Format Files, and then right-click the directory to select the start formatting file.

On "how to automatically format vue files in vscode" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report