互联网技术 · 2024年2月19日

实现vscode的一键代码格式规范

这篇文章主要介绍了vscode 一键规范代码格式的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。

使用vscode的过程中 自己或者push代码以后 代码的格式可能会出现错乱,

作为一个成熟的开发 , 当然应该遵守一些代码规范, 首先代码整洁度应该排在第一位

使用vscode 格式化代码 在少量的情况下 可能可以手动去修改格式, 但在大量格式排版不对齐的情况下, 应该怎么做?

vscode一键规范代码格式的实现

在右侧用户设置中可以对当前编辑器默认的进行更改

下面的复制到用户设置中, ctrl + s 即可完成对代码的规范

{
“editor.detectIndentation”: false,
“editor.tabSize”: 2,
“editor.formatOnSave”: true,
“eslint.autoFixOnSave”: true,
“eslint.validate”: [
“javascript”,
“javascriptreact”,
{
“language”: “vue”,
“autoFix”: true
}
],
“prettier.eslintIntegration”: true,
“prettier.semi”: false,
“prettier.singleQuote”: true,
“javascript.format.insertSpaceBeforeFunctionParenthesis”: true,
“vetur.format.defaultFormatter.html”: “js-beautify-html”,
“vetur.format.defaultFormatter.js”: “vscode-typescript”,
“vetur.format.defaultFormatterOptions”: {
“js-beautify-html”: {
“wrap_attributes”: “force-aligned”
}
},
“stylusSupremacy.insertColons”: false,
“stylusSupremacy.insertSemicolons”: false,
“stylusSupremacy.insertBraces”: false,
“stylusSupremacy.insertNewLineAroundImports”: false,
“stylusSupremacy.insertNewLineAroundBlocks”: false
}

vscode一键规范代码格式的实现

到此这篇关于vscode 一键规范代码格式的实现的文章就介绍到这了,更多相关vscode 规范代码格式内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册