vscode 一键规范代码格式的实现
作者:zm_miner 时间:2022-01-14 17:24:53
使用vscode的过程中 自己或者push代码以后 代码的格式可能会出现错乱,
作为一个成熟的开发 , 当然应该遵守一些代码规范, 首先代码整洁度应该排在第一位
使用vscode 格式化代码 在少量的情况下 可能可以手动去修改格式, 但在大量格式排版不对齐的情况下, 应该怎么做?
文件 -> 首选项 -> 设置 -> {}
在右侧用户设置中可以对当前编辑器默认的进行更改
下面的复制到用户设置中, ctrl + s
即可完成对代码的规范
{
// vscode默认启用了根据文件类型自动设置tabsize的选项
"editor.detectIndentation": false,
// 重新设定tabsize
"editor.tabSize": 2,
// #每次保存的时候自动格式化
"editor.formatOnSave": true,
// #每次保存的时候将代码按eslint格式进行修复
"eslint.autoFixOnSave": true,
// 添加 vue 支持
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "vue",
"autoFix": true
}
],
// #让prettier使用eslint的代码格式进行校验
"prettier.eslintIntegration": true,
// #去掉代码结尾的分号
"prettier.semi": false,
// #使用带引号替代双引号
"prettier.singleQuote": true,
// #让函数(名)和后面的括号之间加个空格
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
// #这个按用户自身习惯选择
"vetur.format.defaultFormatter.html": "js-beautify-html",
// #让vue中的js按编辑器自带的ts格式进行格式化
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "force-aligned"
// #vue组件中html代码格式化样式
}
},
// 格式化stylus, 需安装Manta's Stylus Supremacy插件
"stylusSupremacy.insertColons": false, // 是否插入冒号
"stylusSupremacy.insertSemicolons": false, // 是否插入分好
"stylusSupremacy.insertBraces": false, // 是否插入大括号
"stylusSupremacy.insertNewLineAroundImports": false, // import之后是否换行
"stylusSupremacy.insertNewLineAroundBlocks": false // 两个选择器中是否换行
}
来源:https://blog.csdn.net/zm_miner/article/details/94416776
标签:vscode,规范,代码,格式
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
合理利用页面标签元素有利用搜索引擎收录
2008-11-03 11:49:00
数据分页显示按钮,自动获取url链接
2009-06-22 12:59:00
python自动发邮件库yagmail的示例代码
2022-01-15 14:23:26
![](https://img.aspxhome.com/file/2023/0/83720_0s.png)
golang中net的tcp服务使用
2023-08-30 10:54:14
![](https://img.aspxhome.com/file/2023/8/93658_0s.webp)
Windows下安装python2和python3多版本教程
2021-06-06 07:10:59
![](https://img.aspxhome.com/file/2023/7/111887_0s.png)
python人工智能tensorflow函数tf.get_variable使用方法
2021-09-14 22:52:09
基于DataFrame改变列类型的方法
2021-05-30 05:36:42
基于Python实现一个简易的数据管理系统
2023-08-14 11:49:38
![](https://img.aspxhome.com/file/2023/4/92274_0s.png)
基于pandas中expand的作用详解
2022-02-04 06:53:53
通过事务日志解决SQL Server常见四大故障
2009-03-25 16:06:00
python实现大转盘抽奖效果
2023-12-16 13:50:30
![](https://img.aspxhome.com/file/2023/1/72081_0s.jpg)
python使用Thread的setDaemon启动后台线程教程
2023-09-29 05:49:26
idea创建springMVC框架和配置小文件的教程图解
2021-04-03 15:22:54
![](https://img.aspxhome.com/file/2023/1/78601_0s.png)
Pthon批量处理将pdb文件生成dssp文件
2021-10-07 13:11:04
windows 2000 IIS下配置Php+Mysql+zend的图文教程(完整版)
2007-06-15 10:51:00
![](https://img.aspxhome.com/file/uploadpic/20076/15/200761515925137.gif)
Python读取和存储yaml文件的方法
2023-03-26 10:23:44
![](https://img.aspxhome.com/file/2023/1/130571_0s.png)
python处理大日志文件
2021-11-09 22:21:14
Python使用海龟绘图实现贪吃蛇游戏
2022-01-03 15:21:28
Servlet实现文件上传,可多文件上传示例
2023-08-25 02:31:29
![](https://img.aspxhome.com/file/2023/3/56243_0s.jpg)
学习win32com操作word之Range精讲
2021-05-13 11:36:58
![](https://img.aspxhome.com/file/2023/8/87548_0s.png)