rea t插件 vscode_关于 vscode 的使用,及个人的配置

本文介绍了如何在VSCode中设置代码片段,包括局部和全局的使用,并分享了作者个人安装的一系列插件,如Vetur、Chinese (Simplified) Language Pack、Auto Close Tag、Color Picker等,提升了编码效率和体验。最后,提供了作者的VSCode配置文件,供读者参考。
摘要由CSDN通过智能技术生成

代码片段

首先是代码片段,包括全局和局部:

局部

使用方法:

706f2ea56ed007e091a563896a1f758e.png

.vue文件下,输入 vue 即可生成模版,当然这些模版片段,我们自己也可以设置,可以根据自己的需求写。

{
  "vue-template": {
    "prefix": "vue",
    "body": [
      "<template>",
      "  <div class="$1">n",
      "  </div>",
      "</template>",
      "",
      "<script>",
      "export default {",
      "  name: '$1',",
      "}",
      "</script>",
      "",
      "<style lang="stylus" scoped>n",
      "</style>"
    ]
  }
}
prefix项,对应指令, body就是模版样式;

全局

定义位置:

981d792ad464aa68d5f455bcd68416cb.png
下面是我的定义好的全局指令:
{
  "Lamda 表达式": {
    "scope": "javascript,typescript",
    "prefix": "arrow",
    "body": ["($1) => {$2}"],
    "description": "箭头函数"
  },
  "注释模板": {
    "scope": "javascript,typescript,css,stylus",
    "prefix": "zhushi",
    "body": ["/**", "* @author: 倪凡", "* @description: $1", "*/"],
    "description": "注释"
  },
  "forin循环": {
    "scope": "javascript,typescript",
    "prefix": ["forin"],
    "body": ["for (let ${2:key} in ${1:json}) {", "t$0", "}"],
    "description": "forin循环"
  },
  "函数声明模板": {
    "scope": "javascript,typescript",
    "prefix": ["funct", "func", "function"],
    "body": ["function ${1:name} ($2) { ", "t$3", "}"],
    "description": "函数声明模板"
  },
  "函数表达式模板": {
    "scope": "javascript,typescript",
    "prefix": ["cfunct", "cfunc", "cfunction"],
    "body": ["let ${1:name} = function ($3) { ", "t$4", "}"],
    "description": "函数表达式模板"
  },
  "方法注释模板": {
    "scope": "javascript,typescript",
    "prefix": "fzhushi",
    "body": [
      "/**",
      "* @author: 倪凡",
      "* @description: $1",
      "* @param {$2} $3",
      "* @returns {$4} $5",
      "*/"
    ],
    "description": "注释方法"
  },
  "打印日志": {
    "scope": "javascript,typescript",
    "prefix": ["log"],
    "body": ["console.log($1)"],
    "description": "console.log打印日志"
  }
}
全局一次性可以定义多个,名字加配置项, scope是使用的范围,然后我们在对应范围内使用想要的指令即可:

e1c2ce6ab23ef49045bf3015a1eee01d.png

使用插件

vscode重点就是数不尽的插件,下面介绍下自己安装的一些插件:

Chinese

中文,没什么说的,下载后第一个安装的

Vetur

使用 Vue,必定会安装Vetur,可以识别 vue 文件,带格式化功能(但最好不用这个格式化)

Auto Close Tag

帮你自动闭合标签,有时不是很准确,不过还是可以的。

Auto Rename Tag

帮你自动更新标签,在标签结尾使用没用,在开始标签使用。

Color Picker

颜色选择器,没什么用,可以出现颜色样板,滑动去色

Css Peek

点击 html 会自动跳转到对应的 css 位置

Dracula Official

最喜欢的一款皮肤,连顶部的 Tabs 栏都都标记颜色,真的很棒。

Manta's Stylus Suppremacy

stylus 的格式化工具,自定义强。

打开用户设置,点开右上角的文本配置,写下代码:
// 冒号,根据自己需求
    "stylusSupremacy.insertColons": false,
    // 分号,也是
    "stylusSupremacy.insertSemicolons": false,
    "stylusSupremacy.insertBraces": false,
    "stylusSupremacy.insertNewLineAroundImports": false,
    "stylusSupremacy.insertNewLineAroundBlocks": false,
Prettier-code formatter

格式化软件,支持语言超级多,而且自定义强,定制自己的代码风格, Vuter 加它,完美解决各种不喜欢,个人不喜欢冒号和引号,所以这个插件完美解决我的需求。

Markdown Preview

markdown 编写插件,可以让你的 vscode 瞬间变成记笔记写博客的软件, 无需别的编辑器。

最后附上个人的 vscode 配置

{
  "workbench.list.automaticKeyboardNavigation": false,
  "terminal.integrated.fontFamily": "Hack Nerd Font",
  "terminal.integrated.fontSize": 14,
  "git.enabled": true,
  "git.path": null,
  "editor.foldingStrategy": "indentation",
  "editor.fontSize": 14,
  "editor.wordWrap": "on",
  "terminal.integrated.shell.osx": "/bin/zsh",
  "vsicons.dontShowNewVersionMessage": true,
  "window.zoomLevel": 1,
  "editor.renderLineHighlight": "gutter",
  "editor.tabCompletion": "on",
  "explorer.confirmDragAndDrop": false,
  "javascript.updateImportsOnFileMove.enabled": "always",
  "git.enableSmartCommit": true,
  "javascript.implicitProjectConfig.experimentalDecorators": true,
  "workbench.colorTheme": "Cobalt2",
  "material-icon-theme.activeIconPack": "none",
  "extensions.autoUpdate": false,
  "update.showReleaseNotes": false,
  "extensions.autoCheckUpdates": false,
  "editor.tabSize": 2,
  "breadcrumbs.enabled": false,
  "liveServer.settings.donotShowInfoMsg": true,
  "diffEditor.renderSideBySide": true,
  "markdown.preview.fontSize": 12,
  "editor.rename.enablePreview": false,
  "terminal.external.osxExec": "iTerm.app",
  "sync.forceDownload": false,
  "sync.forceUpload": true,
  "sync.gist": "fc2fd8b2848fb7255034f69d68ff5115",
  "sync.removeExtensions": false,
  "sync.quietSync": false,
  "editor.quickSuggestions": {
    "strings": true
  },
  "cSpell.enableFiletypes": ["vue", "js", "html"],
  "eslint.enable": true, // 是否开启检测
  "eslint.options": {
    "extensions": [".js", ".vue"]
  },
  "eslint.validate": [
    {
      "language": "vue",
      "autoFix": true
    },
    {
      "language": "javascript",
      "autoFix": true
    },
    {
      "language": "html",
      "autoFix": true
    },
    "typescript",
    "javascriptreact",
    "typescriptreact"
  ],
  "editor.detectIndentation": false,
  "files.saveConflictResolution": "overwriteFileOnDisk",
  "eslint.format.enable": true,
  "vetur.format.defaultFormatterOptions": {
    "prettier": {
      "singleQuote": true,
      "semi": false,
      "trailingComma": "none",
      "eslintIntegration": true,
      "arrowParens": "avoid"
    },
    "scss": "pretter",
    "js": "prettier",
    "ts": "prettier",
    "prettyhtml": {
      "printWidth": 80
    }
  },
  "[vue]": {
    "editor.defaultFormatter": "octref.vetur"
  },
  "prettier.semi": false,
  "prettier.singleQuote": true,
  "[javascript]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint"
  },
  "files.autoSave": "afterDelay",
  "editor.formatOnPaste": true,
  "workbench.enableExperiments": false,
  "update.mode": "none",
  "telemetry.enableTelemetry": false,
  "telemetry.enableCrashReporter": false,
  "[javascriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "prettier.disableLanguages": ["vue"],
  "editor.highlightActiveIndentGuide": false,
  "editor.renderIndentGuides": false,
  "editor.minimap.enabled": true,
  "editor.renameOnType": true,
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "explorer.confirmDelete": false,
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.suggest.snippetsPreventQuickSuggestions": true,
  "path-intellisense.mappings": {
    "@": "${workspaceRoot}/src"
  },
  "path-intellisense.autoSlashAfterDirectory": true,
  "path-intellisense.extensionOnImport": true,
  "eslint.autoFixOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "workbench.startupEditor": "newUntitledFile",
  "[typescript]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint"
  },
  "git.ignoreMissingGitWarning": true,
  "editor.fontFamily": "'Cascadia Code'",
  "editor.fontLigatures": true,
  "editor.fontWeight": "normal",
  "vim.hlsearch": true,
  "vim.easymotion": false,
  "vim.leader": " ",
  "editor.lineHeight": 20,
  "vim.foldfix": true,
  "workbench.iconTheme": "vscode-icons",
  "editor.wordSeparators": "`~!@#$%^&*()=+[{]}|;:'",.<>/?",
  "editor.renderWhitespace": "all",
  "vim.normalModeKeyBindingsNonRecursive": [
    {
      "before": [",", "j"],
      "after": ["^"]
    },
    {
      "before": [",", "k"],
      "after": ["$"]
    },
    {
      "before": ["<leader>", "p"],
      "commands": ["workbench.action.quickOpen"]
    },
    {
      "before": ["<C-o>"],
      "commands": ["workbench.action.navigateBack"]
    },
    {
      "before": ["<leader>", "s"],
      "commands": ["workbench.action.quickOpen"]
    },
    {
      "before": ["<C-i>"],
      "commands": ["workbench.action.navigateForward"]
    },
    {
      "before": ["<leader>", "f"],
      "commands": ["editor.action.formatDocument"]
    },
    {
      "before": ["<leader>", "w"],
      "commands": ["workbench.action.files.save"]
    },
    {
      "before": ["<leader>", "n"],
      "commands": [":nohl"]
    },
    {
      "before": ["R"],
      "after": ["g", "t"]
    },
    {
      "before": ["E"],
      "after": ["g", "T"]
    },
    {
      "before": ["/"],
      "commands": ["actions.find"]
    },
    {
      "before": ["<leader>", "/"],
      "commands": ["editor.action.startFindReplaceAction"]
    }
  ],
  "vim.visualModeKeyBindingsNonRecursive": [
    {
      "before": [",", "j"],
      "after": ["^"]
    },
    {
      "before": [",", "k"],
      "after": ["$"]
    }
  ]
}

可以直接粘贴到自己的vscode中,如果不用vim则可以不安装vim或者屏蔽即可,其他暗色的插件都可以安装,再根据自己的需求来调整。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值