vs code 相关设置

vs code 相关设置

  1. 格式化代码

第一步 安装相关插件↓插件列表

  • ESLint
  • Vetur
  • Prettier Code formatter

第二步 配置setting.json

{
 "workbench.startupEditor": "newUntitledFile",
 "files.autoSave": "off", // 关闭文件自动保存,避免开发时候页面变化
 "editor.tabSize": 2, // tab距离
 "editor.formatOnSave": true, // 在保存时自动格式化
 "editor.minimap.enabled": false, // 关闭右侧快速预览
 "files.eol": "\n", // 设定文件的换行符,\n(linux模式)或\r\n(win模式)
 "editor.detectIndentation": false, // 关闭vscode的缩进检查
 "editor.fontSize": 14, //设置文字大小
 "editor.lineHeight": 0, //设置文字行高
 "editor.lineNumbers": "on", //开启行数提示
 "prettier.singleQuote": true, // 使用单引号
 "prettier.printWidth": 220, // 每行不超过220
 "prettier.jsxBracketSameLine": true,
 "prettier.jsxSingleQuote": true,
 "editor.quickSuggestions": {
   //开启自动显示建议
   "other": true,
   "comments": true,
   "strings": true
 },
 "window.zoomLevel": 0, // 调整窗口的缩放级别
 //根据文件后缀名定义vue文件类型
 "files.associations": {
   "*.vue": "vue"
 },
 // 为各类文件制定Fatmatter插件
 "[vue]": {
   "editor.defaultFormatter": "esbenp.prettier-vscode" // 采用prettier处理格式化
 },
 "[javascript]": {
   "editor.defaultFormatter": "esbenp.prettier-vscode"
 },
 "[json]": {
   "editor.defaultFormatter": "esbenp.prettier-vscode"
 },
 "[jsonc]": {
   "editor.defaultFormatter": "vscode.json-language-features"
 },
 // ESLint 的相关配置
 "eslint.validate": [
   "javascript",
   "javascriptreact",
   "vue"
 ],
 // "eslint.autoFixOnSave": true,  很多插件提示这么设定,但实际vscode中已经弃用这个设置,改用下面的方式。
 "editor.codeActionsOnSave": {
   // 保存时触发的事件
   "source.fixAll.eslint": true // 自动fix eslint
 },
 "eslint.run": "onSave", // 保存就校验
 // 函数名后增加空格
 "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
 "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
 "workbench.iconTheme": "vscode-icons",
 "workbench.colorCustomizations": {
   "editorBracketHighlight.foreground1": "#ffd700",
   "editorBracketPairGuide.activeBackground1": "#ffd7007f",
   "editorBracketHighlight.foreground2": "#da70d6",
   "editorBracketPairGuide.activeBackground2": "#da70d67f",
   "editorBracketHighlight.foreground3": "#87cefa",
   "editorBracketPairGuide.activeBackground3": "#87cefa7f",
   "editorBracketHighlight.foreground4": "#ffd700",
   "editorBracketPairGuide.activeBackground4": "#ffd7007f",
   "editorBracketHighlight.foreground5": "#da70d6",
   "editorBracketPairGuide.activeBackground5": "#da70d67f",
   "editorBracketHighlight.foreground6": "#87cefa",
   "editorBracketPairGuide.activeBackground6": "#87cefa7f",
   "editorBracketHighlight.unexpectedBracket.foreground": "#ff0000",
 },
 "editor.bracketPairColorization.enabled": true,
 "editor.guides.bracketPairs": "active",
 "prettier.semi": false,
 "settingsSync.ignoredSettings": [], // 每行结尾加;
 "prettier.trailingComma": "none" // 对象最后一个元素 不加逗号
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值