Home>Article>Development Tools> Detailed explanation of how to format vue files in vscode
This article will introduce to you the method of formatting vue files invscode, including the method of customizing shortcut keys. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
[Recommended learning: "vscode tutorial"]
"beautify.language": { "js": { "type": [ "javascript", "json" ], "filename": [ ".jshintrc", ".jsbeautify" ] }, "css": [ "css", "scss" ], "html": [ "htm", "html", "vue"//在这里加上vue ] }
1. Create the .jsbeautifyrc file in the working directory
{ "brace_style": "none,preserve-inline", "indent_size": 2, "indent_char": " ", "jslint_happy": true, "unformatted": [""], "css": { "indent_size": 2 } }
The content of the file is as above, and some of the parameters should be highlighted.
brace_style
, format style, please see the official description for details (to avoid conflicts with eslint’s default check, it is recommended that this attribute be set tonone,preserve-inline)indent_size
, indent length (to avoid conflict with eslint default check, it is recommended that this property be set to2)indent_char
, indent the filled content (full of ♂)jslint_happy:true
, if you want to use it with jslint, please turn on this optionunformatted: ["a","pre"]
, here are the tag types that do not need to be formatted. Note thattemplate
is also not formatted by default. If the template tag of .vue needs to be formatted, please redefine the declaration attribute without template in .jsbeautifyrc..jsbeautifyrc configuration official document address: Click here
2. Enable automatic
Add # in the VSCode configuration file when saving. ##editor.formatOnSave:trueYou can achieve automatic formatting when saving
{ "key": "ctrl+b",//自己定键位 "command": "HookyQR.beautify", "when": "editorFocus" }ps: If you want to modify the editor For the defined shortcut keys, click here to enter the key directly For more programming-related knowledge, please visit:
Programming Video! !
The above is the detailed content of Detailed explanation of how to format vue files in vscode. For more information, please follow other related articles on the PHP Chinese website!