Skip to content

Visual Studio Code 配置

下载小技巧

mac 可直接使用 brew 下载安装

sh
brew install --cask visual-studio-code

官网下载安装

  1. 打开 Visual Studio Code 官网进行下载
  2. 打开下载管理,复制下载链接
  3. 将链接中的域名部分 az764295.vo.msecnd.net 替换为 vscode.cdn.azure.cn

举个 🌰

sh
https://az764295.vo.msecnd.net/stable/abd2f3db4bdb28f9e95536dfa84d8479f1eb312d/VSCode-darwin-universal.zip

替换结果如下

sh
https://vscode.cdn.azure.cn/stable/abd2f3db4bdb28f9e95536dfa84d8479f1eb312d/VSCode-darwin-universal.zip

扩展插件推荐

点击插件 ID 或在扩展商店搜索插件 ID 即可安装

主题相关

插件名插件 ID插件描述
Material Icon ThemePKief.material-icon-theme图标美化
Bluloco Darkuloco.theme-bluloco-dark暗黑风格主题(本人常用)
One Dark Prozhuangtongfa.Material-theme暗黑风格主题
Dracula Officialdracula-theme.theme-dracula暗黑风格主题
Shades of Purpleahmadawais.shades-of-purple紫色主题(来自彤姐的推荐:没有什么比骚更重要)
backgroundshalldie.background自定义背景图

VS Code Themes 在线预览

HTML 相关

插件名插件 ID插件描述
Auto Close Tagformulahendry.auto-close-tag自动添加 HTML / XML 关闭标签
Auto Rename Tagformulahendry.auto-rename-tag自动重命名配对的 HTML / XML 标签
Highlight Matching Tagvincaslt.highlight-matching-tagTag 高亮匹配标记

CSS 相关

插件名插件 ID插件描述
Stylelintstylelint.vscode-stylelintCSS / LESS / SCSS 代码检查
Tailwind CSS IntelliSensebradlc.vscode-tailwindcssTailwind CSS 智能提示
Easy LESSmrcrowl.easy-less保存时自动将 less 自动编译为 css
language-stylussysoev.language-stylus增加对 stylus 的支持
px to remsainoba.px-to-rempxrem 互相转换

Markdown 相关

插件名插件 ID插件描述
markdownlintDavidAnson.vscode-markdownlintMarkdown / CommonMark 标记和样式检查
Markdown Preview Enhancedshd101wyy.markdown-preview-enhanced为 Markdown 增加大纲、导出 PDF PNG JPEG HTML、自定义预览样式
Markdown All in Oneyzhang.markdown-all-in-oneMarkdown 增强,支持表格、自动预览、自动补全、格式化等

语法支持与代码格式检查

插件名插件 ID插件描述
ESLintdbaeumer.vscode-eslint将 ESLint 集成到 VSCode 中
Prettier - Code formatteresbenp.prettier-vscode代码格式化
Code Spell Checkerstreetsidesoftware.code-spell-checker代码拼写检查
Error Lensusernamehw.errorlens突出显示代码错误和警告
Vue 3 Snippetshollowtree.vue-snippetsVue2Vue3 提供代码片段
Vue Language Features (Volar)Vue.volarVue3 文件语法高亮、片段整理、错误检查、格式化
TypeScript Vue Plugin (Volar)Vue.vscode-typescript-vue-plugin用于支持在 TSimport *.vue 文件
Veturoctref.veturVue2 文件语法高亮、片段整理、错误检查、格式化
EditorConfig for VS CodeEditorConfig.EditorConfig增加对 .editorconfig 的支持
DotENVIronGeek.vscode-env.env 文件键值字符串高亮和格式化
shell-formatfoxundermoon.shell-formatshell 脚本格式化
WXML - Language Serviceqiu8310.minapp-vscodeWXML 文件语法高亮、片段整理、错误检查、格式化
Sort package.jsonpsioniq.psi-headerpackage.json 文件进行排序

AI 代码提示和生成

插件名插件 ID插件描述
GitHub CopilotGitHub.copilotGitHub AI 代码提示和生成
GitHub Copilot ChatGitHub.copilot-chatGitHub Copilot 聊天对话
CodeGeeXaminer.codegeex免费的 AI 代码提示和生成、代码翻译、智能问答等

开发体验提升

插件名插件 ID插件描述
Chinese (Simplified) Language Pack for Visual Studio CodeMS-CEINTL.vscode-language-pack-zh-hans中文语言包
GitLens — Git superchargedeamodio.gitlens增强构建在 VSCode 中的 Git 功能
Live Serverritwickdey.LiveServer启动具有实时重新加载功能的本地开发服务
Code Runnerformulahendry.code-runner运行代码段或代码文件
ES7 React/Redux/GraphQL/React-Native snippetsdsznajder.es7-react-js-snippets提供 ES7 中的 JavaScript 和 React / Redux 片段
Pretty Typescript Errorsyoavbls.pretty-ts-errors使 TypeScript 错误更美观、更易于阅读
Auto Importsteoates.autoimport自动查找,解析并提供所有可用导入的代码
Import Costwix.vscode-import-cost在编辑器中显示导入/需要包的大小
Image previewkisstkondoros.vscode-gutter-preview在行号边上、悬停时显示图像预览
Path Intellisensechristian-kohler.path-intellisense自动补全文件路径
npm Intellisensechristian-kohler.npm-intellisense自动补全导入语句中的 npm 模块
es6-string-htmlTobermory.es6-string-htmlES6 模板字符串高亮
Todo TreeGruntfuggly.todo-tree在树视图中显示 TODO FIXME 等注释标记
change-casewmaurer.change-case改变选中的文本的大小写

其他

插件名插件 ID插件描述
WakaTimeWakaTime.vscode-wakatime统计代码编写时间 (WakaTime 官网)
韭菜盒子giscafer.leek-fund看股票、基金实时数据

使用小技巧

删除空行

  1. 打开替换 Alt + ⌘ + F
  2. 输入 ^\s*(?=\r?$)\n
  3. 勾选使用正则表达式 Alt + ⌘ + R
  4. 全部替换 ⌘ + Enter

安装 code 命令

code 命令可以直接打开一个文件或者文件目录

  1. 使用 shift + command + p 打开命令面板
  2. 输入 shell command 进行搜索
  3. 点击 Shell 命令:在 PATH 中安装 “code” 命令
sh
# 在 vscode 中编辑当前目录下的文件
code .

# 在 vscode 中编辑该文件(当文件不存在时会先创建该文件)
code [文件名]

webpack 项目识别 alias

  1. 在项目根目录新建 jsconfig.jsontsconfig.json
  2. 添加以下代码,其中 paths 字段的值要与你项目配置的 alias 一致
json
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "include": ["src"]
}

推荐配置

json
{
    "explorer.compactFolders": false,
    "explorer.confirmDelete": false,
    "go.toolsManagement.autoUpdate": true,
    "go.languageServerExperimentalFeatures": {
        "diagnostics": false
    },
    "[go]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit"
        },
    },
    "[go.mod]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit"
        },
    },
    "go.trace.server": "verbose",
    "go.languageServerFlags": [],
    "editor.fontFamily": "JetBrainsMono Nerd Font, Consolas,  monospace",
    "editor.fontSize": 17,
    "gopls": {
        // Add parameter placeholders when completing a function. 
        "usePlaceholders": false,
        // If true, enable additional analyses with staticcheck. 
        // Warning: This will significantly increase memory usage.   "staticcheck": false, 
    },
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "git.autofetch": true,
    "editor.fontWeight": "normal",
    "git.confirmSync": false,
    "remote.SSH.remotePlatform": {
        "104.243.24.127": "linux",
        "ubuntu": "linux",
        "weason4Ubuntu": "linux",
        "wa": "linux",
        "wa_online": "linux",
        "kali": "linux",
        "Weakali": "linux",
        "weakali_online": "linux",
        "weakali": "linux",
        "thm": "linux"
    },
    "window.zoomLevel": 1,
    "settingsSync.ignoredExtensions": [
        "easycodeai.chatgpt-gpt4-gpt3-vscode",
        "ms-vscode.remote-explorer",
        "ms-vscode-remote.vscode-remote-extensionpack",
        "yuji9511.background",
        "vscjava.vscode-java-pack",
        "lehni.vscode-fix-checksums",
        "ms-vscode-remote.remote-ssh",
        "ms-vscode-remote.remote-ssh-edit",
        "ms-ceintl.vscode-language-pack-zh-hans",
        "ms-azuretools.vscode-docker",
        "ms-vscode-remote.remote-containers",
        "vscjava.vscode-gradle",
        "alibaba-cloud.tongyi-lingma",
        "github.codespaces",
        "eamodio.gitlens",
        "ms-vscode.js-debug-companion",
        "golang.go",
        "ms-azuretools.vscode-containers"
    ],
    "redhat.telemetry.enabled": true,
    "[go][go.mod]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit"
        }
    },
    "baidu.comate.username": "紙燈Stay",
    "baidu.comate.license": "db6bcb0c-95a7-4a58-8fe4-55301a6bd66f",
    "baidu.comate.langSuggestion": {
        "css": true,
        "pug": true,
        "batchfile": true,
        "stata": true,
        "stylus": true,
        "agda": true,
        "csharp": true,
        "java": false,
        "xml": true,
        "powershell": true,
        "makefile": true,
        "zig": true,
        "sass": true,
        "solidity": true,
        "python": true,
        "ocaml": true,
        "tex": true,
        "antlr": true,
        "javascript": true,
        "protocolbuffer": true,
        "tcsh": true,
        "groovy": true,
        "cuda": true,
        "scheme": true,
        "clojure": true,
        "pascal": true,
        "isabelle": true,
        "yacc": true,
        "rmarkdown": true,
        "dart": true,
        "jupyter": true,
        "mermaid": true,
        "lean": true,
        "julia": true,
        "assembly": true,
        "markdown": true,
        "thrift": true,
        "typescript": true,
        "graphql": true,
        "haskell": true,
        "coffeescript": true,
        "standardml": true,
        "r": true,
        "cmake": true,
        "stan": true,
        "php": true,
        "sparql": true,
        "smalltalk": true,
        "scss": true,
        "literateagda": true,
        "vue": true,
        "vhdl": true,
        "emacslisp": true,
        "html": true,
        "others": true,
        "ada": true,
        "swift": true,
        "yaml": true,
        "all": true,
        "matlab": true,
        "commonlisp": true,
        "cpp": true,
        "literatecoffeescript": true,
        "visualbasic": true,
        "swan": true,
        "elm": true,
        "less": true,
        "verilog": true,
        "literatehaskell": true,
        "shell": true,
        "javaserverpages": true,
        "alloy": true,
        "elixir": true,
        "scala": true,
        "erlang": true,
        "racket": true,
        "glsl": true,
        "sql": true,
        "rust": true,
        "bluespec": true,
        "fortran": true,
        "applescript": true,
        "fsharp": true,
        "idris": true,
        "mathematica": true,
        "json": true,
        "perl": true,
        "tcl": true,
        "restructuredtext": true,
        "san": true,
        "augeas": true,
        "sas": true,
        "dockerfile": true,
        "systemverilog": true,
        "go": true,
        "kotlin": true,
        "objectivec": true,
        "prolog": true,
        "ruby": true,
        "awk": true,
        "maple": true,
        "lua": true,
        "xslt": true
    },
    "baidu.comate.enableSecurityEnhancement": false,
    "baidu.comate.linePreferMode": "auto",
    "security.workspace.trust.untrustedFiles": "open",
    "backgroundCover.imagePath": "/home/weason/Pictures/demo.png",
    "backgroundCover.opacity": 0.5,
    "winopacity.opacity": 80,
    "background.style": {
        "content": "''",
        "pointer-events": "none",
        "position": "absolute",
        "z-index": "99999",
        "width": "100%",
        "height": "100%",
        "background-position": "100% 100%",
        "background-repeat": "no-repeat",
        "opacity": 1
    },
    "terminal.integrated.fontSize": 16,
    "glassit.alpha": 243,
    "files.autoSave": "afterDelay",
    "files.autoGuessEncoding": true,
    "editor.smoothScrolling": true,
    "workbench.list.smoothScrolling": true,
    "terminal.integrated.smoothScrolling": true,
    "editor.cursorBlinking": "smooth",
    "editor.cursorSmoothCaretAnimation": "on",
    "editor.wordWrap": "on",
    "editor.acceptSuggestionOnEnter": "smart",
    "window.dialogStyle": "custom",
    "debug.showBreakpointsInOverviewRuler": true,
    "editor.minimap.autohide": true,
    "baidu.comate.customizeService": "https://comate.baidu.com",
    "git.enableSmartCommit": true,
    "terminal.integrated.defaultProfile.linux": "zsh",
    "java.imports.gradle.wrapper.checksums": [
        {
            "sha256": "e2b82129ab64751fd40437007bd2f7f2afb3c6e41a9198e628650b22d5824a14",
            "allowed": true
        }
    ],
    "java.configuration.maven.userSettings": "",
    "editor.unicodeHighlight.nonBasicASCII": false,
    "markdown-preview-enhanced.revealjsTheme": "beige.css",
    "markdown-preview-enhanced.enablePreviewZenMode": false,
    "pasteImage.path": "assets",
    "pasteImage.defaultName": "YMMDD_HHmmss",
    "code-runner.runInTerminal": true,
    "window.customTitleBarVisibility": "windowed",
    "terminal.integrated.shellIntegration.enabled": false,
    "terminal.integrated.cursorStyle": "line",
    "[markdown]": {
        "editor.defaultFormatter": "yzhang.markdown-all-in-one"
    },
    "pasteImage.insertPattern": "<div align=left><img width = '400' src = './${imageFilePath}'></div>",
    "github.copilot.advanced": {

    
    },
    "github.copilot.editor.enableInlineChat": false,
    "diffEditor.ignoreTrimWhitespace": false,
    "workbench.editor.enablePreview": false,
    "settingsSync.ignoredSettings": [
        "http.proxyStrictSSL"
    ],
    "editor.overtypeCursorStyle": "line",
    "workbench.layoutControl.enabled": false,
    "markdown-preview-enhanced.previewTheme": "github-light.css",
    "markdown-preview-enhanced.alwaysShowBacklinksInPreview": false,
    "diffEditor.hideUnchangedRegions.enabled": true,
    "launch": {
        "configurations": [
            {
                "name": "Launch Chrome",
                "request": "launch",
                "type": "chrome",
                "url": "http://localhost:8080",
                "webRoot": "${workspaceFolder}"
            }
        ]
    },
    "workbench.sideBar.location": "right",
    "mcp": {

        "inputs": [],
        "servers": {
            // "n8n": {
            //     "command": "npx",
            //     "args": [
            //         "-y",
            //         "supergateway",
            //         "--sse",
            //         "https://n8n-mmplospk.ap-northeast-1.clawcloudrun.com/mcp/54339f77-56de-4cd8-bc54-10c91079857a/sse"
            //     ]
            // },
            // "firecrawl": {
            //     "command": "npx",
            //     "args": [
            //         "-y",
            //         "firecrawl-mcp"
            //     ],
            //     "env": {
            //         "FIRECRAWL_API_KEY":"fc-548e8179ec3b4421a439a38c5a8f1ea6"
            //     }
            // }
        }
    },
    "database-client.autoSync": true,
    "explorer.fileNesting.patterns": {
        "*.ts": "${capture}.js",
        "*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
        "*.jsx": "${capture}.js",
        "*.tsx": "${capture}.ts",
        "tsconfig.json": "tsconfig.*.json",
        "package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, bun.lock",
        "*.sqlite": "${capture}.${extname}-*",
        "*.db": "${capture}.${extname}-*",
        "*.sqlite3": "${capture}.${extname}-*",
        "*.db3": "${capture}.${extname}-*",
        "*.sdb": "${capture}.${extname}-*",
        "*.s3db": "${capture}.${extname}-*"
    },
    "workbench.activityBar.location": "top",
    "window.commandCenter": false,
    "inlineChat.hideOnRequest": true,
    "inlineChat.enableV2": true,
    "workbench.editor.empty.hint": "hidden",
    "workbench.iconTheme": "material-icon-theme",
    "docker.extension.dockerEngineAvailabilityPrompt": false,
    "workbench.colorTheme": "Visual Studio Dark",
    "workbench.statusBar.visible": false,
}

快捷键

json
// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "ctrl+shift+k",
        "command": "workbench.view.debug",
        "when": "viewContainer.workbench.view.debug.enabled"
    },
    {
        "key": "ctrl+shift+d",
        "command": "-workbench.view.debug",
        "when": "viewContainer.workbench.view.debug.enabled"
    },
    {
        "key": "ctrl+shift+d",
        "command": "editor.action.deleteLines",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+shift+k",
        "command": "-editor.action.deleteLines",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+shift+oem_2",
        "command": "editor.action.triggerParameterHints",
        "when": "editorHasSignatureHelpProvider && editorTextFocus"
    },
    {
        "key": "ctrl+shift+space",
        "command": "-editor.action.triggerParameterHints",
        "when": "editorHasSignatureHelpProvider && editorTextFocus"
    },
    {
        "key": "alt+oem_2",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+space",
        "command": "-editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+alt+t",
        "command": "workbench.action.toggleMaximizedPanel"
    },
    {
        "key": "shift+alt+r",
        "command": "editor.action.sourceAction"
    },
    {
        "key": "ctrl+h",
        "command": "-editor.action.startFindReplaceAction",
        "when": "editorFocus || editorIsOpen"
    },
    {
        "key": "ctrl+h",
        "command": "workbench.action.previousEditor"
    },
    {
        "key": "ctrl+l",
        "command": "workbench.action.nextEditor"
    },
    {
        "key": "ctrl+i",
        "command": "-editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly && !suggestWidgetVisible"
    },
    {
        "key": "ctrl+i",
        "command": "-focusSuggestion",
        "when": "suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"
    },
    {
        "key": "shift+alt+b",
        "command": "workbench.action.toggleStatusbarVisibility"
    }
]

代码片段

json
{
    "markdown code block": {
        "scope": "markdown",
        "prefix": "code",
        "body": [
            "```${1:js}",
            "$2",
            "```"
        ],
        "description": "markdown 块级代码"
    },
    "vitepress custom containers info": {
        "scope": "markdown",
        "prefix": "info",
        "body": [
            "::: info $1",
            "$2",
            ":::"
        ],
        "description": "vitepress 自定义容器 info"
    },
    "vitepress custom containers tip": {
        "scope": "markdown",
        "prefix": "tip",
        "body": [
            "::: tip $1",
            "$2",
            ":::"
        ],
        "description": "vitepress 自定义容器 tip"
    },
    "vitepress custom containers warn": {
        "scope": "markdown",
        "prefix": "warn",
        "body": [
            "::: warning $1",
            "$2",
            ":::"
        ],
        "description": "vitepress 自定义容器 warning"
    },
    "vitepress custom containers danger": {
        "scope": "markdown",
        "prefix": "danger",
        "body": [
            "::: danger $1",
            "$2",
            ":::"
        ],
        "description": "vitepress 自定义容器 danger"
    },
    "vitepress custom containers details": {
        "scope": "markdown",
        "prefix": "details",
        "body": [
            "::: details $1",
            "$2",
            ":::"
        ],
        "description": "vitepress 自定义容器 details"
    },
    "Large Bold Context Span": {
        "scope": "markdown",
        "prefix": "lcontent",
        "body": [
            "<span style=\"font-size: 23px;\">**${1:content}**</span>"
        ],
        "description": "Inserts a span with large, bold 'content' text"
    },
    "superscript": {
        "scope": "markdown",
        "prefix": "sup",
        "body": [
            "${1:content}<sup>${2:content}</sup>"
        ],
        "description": "math superscript"
    },
    "typescript challenges": {
        "scope": "markdown",
        "prefix": "challenge",
        "body": [
            "### $1",
            "",
            "$2",
            "",
            "```ts",
            "type result$3",
            "```",
            "",
            "**实现**:",
            "",
            "```ts",
            "$4",
            "```"
        ],
        "description": "typescript 类型体操"
    }
}

其他

扩展插件开发

Released under the MIT License.