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

What are the methods of formatting vscode code

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces the methods of vscode code formatting, which is very detailed and has a certain reference value. Friends who are interested must read it!

The shortcut keys for vs code format code are as follows:

On WindowsShift+Alt+F

On MacShift+Option+F

On UbuntuCtrl+Shift+I

But the built-in format can not meet my needs, at this time, I have to say that the plug-in is good.

1. The code is formatted in eslint style

Plug-in required: eslint

Add to the settings:

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

Eslint.autoFixOnSave is used to format automatically when saved, but only javascript .js files are supported by default.

The file type used by eslint.validate to configure the role.

Then when you save the code, it is automatically formatted in eslint style (you need to save it multiple times).

2. HTML format code indentation

Plug-in required: Vetur

Vetur is a very powerful plug-in that provides powerful support for vs code to write Vue code as well as most mainstream front-end development scripts. For more information, please see the-> Vetur document here.

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

To allow HTML code to be formatted and indented, add the following:

"vetur.format.defaultFormatter.html": "prettier"

Then use the shortcut keys to format the code.

These are all the contents of this article entitled "what are the ways to format vscode code?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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