笨比作者原本使用 Sublime Text 4 作为主力代码编辑器,最近深感 VS Code 好香,遂重新入坑。
本文将简述笨比作者配置 VS Code 的过程,给大家做一个参考。
笨比作者主要有如下需求:
- C++(算法竞赛)
- Python
- Rust
- Markdown
- Nushell
来自 Sublime Text
可以使用 Sublime Text Keymap and Settings Importer 这个微软官方出的插件把一些 Sublime 的配置和键位绑定迁移过来。笨比作者并不想迁移,就不细说了。
好康好康编辑器
首先装个中文语言包:Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code,装完后右下角会问你是否切换语言,切就对了。把弹窗点掉的朋友们可以按 F1 搜 Configure Display Language,一样能切。
接下来是好看好看主题,作者使用的是 Catppuccin for VSCode 插件中的 Catppuccin Mocha,因为保留着对 Neovim 的独特情怀装了一个 Tokyo Night,一次都没用上。文件图标主题用的 Catppuccin Icons for VSCode,产品图标主题是 Developer’s theme。
Catppuccin for VSCode 建议我们这么写,反正我没写。
1 2 3 4 5
| { "editor.semanticHighlighting.enabled": true, "terminal.integrated.minimumContrastRatio": 1, "window.titleBarStyle": "custom", }
|
原版错误提示不好看,装上 Error Lens。
喜欢平滑动画,开启!
1 2 3 4
| { "editor.smoothScrolling": true, "editor.cursorSmoothCaretAnimation": "explicit", }
|
字体使用的是自己编译的 Maple Mono NF CN Light,编译选项放在下面啦,也可以来这里自取编译好的版本。
config.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| { "family_name": "Maple Mono", "use_hinted": true, "pool_size": 4, "enable_ligature": true, "ttfautohint_param": {}, "feature_freeze": { "cv01": "enable", "cv02": "ignore", "cv03": "ignore", "cv04": "ignore", "cv05": "ignore", "cv06": "ignore", "cv07": "ignore", "cv08": "ignore", "cv31": "ignore", "cv32": "ignore", "cv33": "ignore", "cv34": "ignore", "cv35": "ignore", "cv36": "ignore", "cv37": "ignore", "cv38": "ignore", "cv39": "ignore", "cv40": "ignore", "cv41": "ignore", "cv61": "enable", "cv62": "enable", "cv63": "ignore", "cv64": "ignore", "cv65": "enable", "cv96": "ignore", "cv97": "ignore", "cv98": "ignore", "cv99": "ignore", "ss01": "ignore", "ss02": "ignore", "ss03": "ignore", "ss04": "ignore", "ss05": "ignore", "ss06": "ignore", "ss07": "ignore", "ss08": "ignore", "ss09": "ignore", "ss10": "ignore", "ss11": "enable", "zero": "ignore" }, "nerd_font": { "enable": true, "version": "3.4.0", "mono": false, "use_font_patcher": false, "glyphs": [ "--complete" ], "extra_args": [] }, "cn": { "enable": true, "with_nerd_font": true, "fix_meta_table": true, "clean_cache": false, "narrow": false, "use_hinted": false, "use_static_base_font": true, "scale_factor": 1.0 } }
|
用我的配置的话,进行如下设置就有连字啦。
1 2 3
| { "editor.fontLigatures": "'calt', 'cv01', 'cv61', 'cv62', 'cv65', 'ss11'", }
|
如果你想要 VS Code 灵动灵动灵动,可以试试 Custom CSS and JS Loader + VSCode Animations。
记得调调 UI 大小还有字号。
好写好写 C++
前置操作:在 msys2 中安装 gcc 和 clang。可以使用 ucrt 或者 mingw 环境捏,clang 环境好像是装不了 gcc 的捏。作者装的包列在下面了,可供参考。很多是偷懒直接装的 toolchain 组。
pacman -Qe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| $ pacman -Qe base 2022.06-1 base-devel 2024.11-1 filesystem 2025.05.08-2 git 2.50.1-1 mingw-w64-clang-x86_64-clang 20.1.8-1 mingw-w64-clang-x86_64-clang-analyzer 20.1.8-1 mingw-w64-clang-x86_64-clang-libs 20.1.8-1 mingw-w64-clang-x86_64-clang-tools-extra 20.1.8-1 mingw-w64-clang-x86_64-compiler-rt 20.1.8-1 mingw-w64-clang-x86_64-crt-git 13.0.0.r79.g584661e80-2 mingw-w64-clang-x86_64-headers-git 13.0.0.r79.g584661e80-1 mingw-w64-clang-x86_64-libc++ 20.1.8-1 mingw-w64-clang-x86_64-libmangle-git 13.0.0.r79.g584661e80-1 mingw-w64-clang-x86_64-libunwind 20.1.8-1 mingw-w64-clang-x86_64-libwinpthread 13.0.0.r79.g584661e80-1 mingw-w64-clang-x86_64-lld 20.1.8-1 mingw-w64-clang-x86_64-lldb 20.1.8-1 mingw-w64-clang-x86_64-llvm 20.1.8-1 mingw-w64-clang-x86_64-llvm-libs 20.1.8-1 mingw-w64-clang-x86_64-llvm-openmp 20.1.8-1 mingw-w64-clang-x86_64-llvm-tools 20.1.8-1 mingw-w64-clang-x86_64-make 4.4.1-3 mingw-w64-clang-x86_64-pkgconf 1~2.5.1-1 mingw-w64-clang-x86_64-tools-git 13.0.0.r79.g584661e80-1 mingw-w64-clang-x86_64-winpthreads 13.0.0.r79.g584661e80-1 mingw-w64-clang-x86_64-winstorecompat-git 13.0.0.r79.g584661e80-1 mingw-w64-ucrt-x86_64-binutils 2.45-1 mingw-w64-ucrt-x86_64-crt-git 13.0.0.r79.g584661e80-2 mingw-w64-ucrt-x86_64-gcc 15.1.0-8 mingw-w64-ucrt-x86_64-gdb 16.3-1 mingw-w64-ucrt-x86_64-gdb-multiarch 16.3-1 mingw-w64-ucrt-x86_64-headers-git 13.0.0.r79.g584661e80-1 mingw-w64-ucrt-x86_64-libmangle-git 13.0.0.r79.g584661e80-1 mingw-w64-ucrt-x86_64-make 4.4.1-3 mingw-w64-ucrt-x86_64-neovim 0.11.3-1 mingw-w64-ucrt-x86_64-pkgconf 1~2.5.1-1 mingw-w64-ucrt-x86_64-tools-git 13.0.0.r79.g584661e80-1 mingw-w64-ucrt-x86_64-winpthreads 13.0.0.r79.g584661e80-1 mingw-w64-ucrt-x86_64-winstorecompat-git 13.0.0.r79.g584661e80-1 mingw-w64-x86_64-binutils 2.45-1 mingw-w64-x86_64-clang 20.1.8-1 mingw-w64-x86_64-clang-analyzer 20.1.8-1 mingw-w64-x86_64-clang-libs 20.1.8-1 mingw-w64-x86_64-clang-tools-extra 20.1.8-1 mingw-w64-x86_64-cmake 4.0.3-1 mingw-w64-x86_64-compiler-rt 20.1.8-1 mingw-w64-x86_64-crt-git 13.0.0.r79.g584661e80-2 mingw-w64-x86_64-gcc 15.1.0-8 mingw-w64-x86_64-gdb 16.3-1 mingw-w64-x86_64-gdb-multiarch 16.3-1 mingw-w64-x86_64-headers-git 13.0.0.r79.g584661e80-1 mingw-w64-x86_64-libmangle-git 13.0.0.r79.g584661e80-1 mingw-w64-x86_64-libwinpthread 13.0.0.r79.g584661e80-1 mingw-w64-x86_64-lld 20.1.8-1 mingw-w64-x86_64-llvm 20.1.8-1 mingw-w64-x86_64-llvm-libs 20.1.8-1 mingw-w64-x86_64-llvm-tools 20.1.8-1 mingw-w64-x86_64-make 4.4.1-3 mingw-w64-x86_64-pkgconf 1~2.5.1-1 mingw-w64-x86_64-tools-git 13.0.0.r79.g584661e80-1 mingw-w64-x86_64-winpthreads 13.0.0.r79.g584661e80-1 mingw-w64-x86_64-winstorecompat-git 13.0.0.r79.g584661e80-1 msys2-runtime 3.6.4-1
|
安装 clangd 插件,补全几乎是开箱即用的,也可以参考网上教程对 clangd.arguments 和 clangd.fallbackFlags 进行一些简要设置。
clangd 提供的参数名称显示有点烦,可以把 editor.inlayHints.enabled 设置成 offUnlessPressed 让它只在 Ctrl + Alt 按下时显示。
C++ 的代码格式化也交给 clangd!
1 2 3 4 5
| { "[cpp]": { "editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd", }, }
|
运行代码就不上 CMake 之类的工具了,用 Code Runner 搞定!设置 code-runner.runInTerminal 让它在控制台里运行,就可以输入了。运行选中部分的特性太烦了,设置 code-runner.ignoreSelection 禁掉它。按个人习惯改一下编译参数,就可以运行了。
1 2 3 4 5 6 7 8
| { "code-runner.runInTerminal": true, "code-runner.executorMap": { "cpp": "Set-Location $dir && g++ -Wall -std=c++17 -lm -O2 \"$fileName\" -o \"$env:TEMP/$fileNameWithoutExt\" && Start-Process cmd.exe -ArgumentList \"/c `\"%temp%/$fileNameWithoutExt`\" & pause\"" }, "code-runner.ignoreSelection": true, }
|
既然是算法竞赛,不得不装 Competitive Programming Helper (cph) 了。同样配置配置。
1 2 3 4 5 6 7 8
| { "cph.general.firstTime": false, "cph.general.defaultLanguage": "cpp", "cph.language.cpp.Args": "-std=c++17 -Wall -lm -O2", "cph.general.defaultLanguageTemplateFileLocation": "D:\\OI\\template.cpp", "cph.general.autoShowJudge": false, }
|
螃蟹神教 Rust
rust-analyzer / Even Better TOML,其他没了。
胶水语言 Python
Python 拓展包开箱即用,就不选其他的了。装一个 Black Formatter 格式化代码,你用别的也行。
1 2 3 4 5
| { "[python]": { "editor.defaultFormatter": "ms-python.black-formatter", }, }
|
你要写 Manim 动画的话可以装一个 Manim Sideview。
方便方便 Markdown
VS Code 自带的 Markdown 浏览已经很牛了,装个 markdownlint 就行了。
好用终端 Nushell
将 VS Code 的默认终端设为 Nushell。
1 2 3
| { "terminal.integrated.defaultProfile.windows": "Nushell", }
|
装个 vscode-nushell-lang 插件用于 .nu 文件的高亮。
方便方便小技巧
开个自动保存,防止电脑突然去世引发的惨案。
我想用快捷键调整字体大小而非 UI 大小!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| [ { "key": "ctrl+oem_minus", "command": "-workbench.action.zoomOut" }, { "key": "ctrl+oem_plus", "command": "-workbench.action.zoomIn" }, { "key": "ctrl+oem_minus", "command": "editor.action.fontZoomOut" }, { "key": "ctrl+oem_plus", "command": "editor.action.fontZoomIn" }, { "key": "ctrl+alt+oem_minus", "command": "workbench.action.terminal.fontZoomOut" }, { "key": "ctrl+alt+oem_plus", "command": "workbench.action.terminal.fontZoomIn" }, ]
|
在设置或键绑定界面再按一下快捷键跳到对应的 json 文件。
1 2 3 4 5 6 7 8 9 10 11 12
| [ { "command": "workbench.action.openSettingsJson", "key": "ctrl+oem_comma", "when": "inSettingsEditor" }, { "command": "workbench.action.openGlobalKeybindingsFile", "key": "ctrl+k ctrl+s", "when": "inKeybindings" }, ]
|
Bracket Select 用来选中括号对中间的所有内容。
CodeSnap 给代码创建漂亮的截图。
Command List 保存常用的指令集。
Dependi 来管理项目依赖。
Git Graph 看 Git 历史,你也可以用 GieLens 或 Git History。
由于笨比作者有高贵的 GitHub 教育福利,可以免费用 Copilot Pro,装个 GitHub Copilot 和 GitHub Copilot Chat。
Live Server 在局域网中共享代码,机房好用。你也可以 Live Share,笨比作者不想用。
Trailing Spaces,因为笨比作者不喜欢行末多余的空格。给操作分配一个快捷键。
1 2 3 4 5 6 7
| [ { "key": "ctrl+alt+t", "command": "trailing-spaces.deleteTrailingSpaces", "when": "editorTextFocus && !editorReadonly" }, ]
|
vscode-luogu,在 VS Code 中看洛谷什么的最棒了。
vscode-pdf,用来看 pdf 的。
如果你想用 Vim 模式,装 Vim 和 Vim Cheatsheet 就行,想学习 Vim 的话额外加一个 Learn Vim。
配置下载
又改了一些,放在[这里](/assets/uploads/Gavin v3.code-profile)了。
装上后搜索 /* ! Modify it !*/
按照自己的情况改一下。