精简版
我个人喜好少而高效的配置,所以这里给出一个简单的配置,适用于大部分人。
%APPDATA%/Code/User/settings.json{ "editor.fontLigatures": true, "editor.cursorBlinking": "phase", "editor.cursorSmoothCaretAnimation": "on", "editor.mouseWheelZoom": true, "editor.renderWhitespace": "boundary", "editor.smoothScrolling": true, "editor.wordWrap": "on", "files.autoGuessEncoding": true, "terminal.integrated.smoothScrolling": true, "workbench.list.smoothScrolling": true, "workbench.editor.wrapTabs": true, "C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: Chromium, IndentWidth: 4}", }
|
详细配置
如果你想获得与我接近的体验,可以选择性地添加以下配置。
显示优化
我常用的主题是 OneDark Pro,图标是 Material Icon Theme。
%APPDATA%/Code/User/settings.json{ "editor.fontFamily": "Sarasa Mono SC, Fira Code, JetBrains Mono, Consolas, 'monospace', system-ui, monospace, Symbols Nerd Font, JetBrainsMono Nerd Font, Hack Nerd Font", "editor.fontLigatures": true, "editor.fontSize": 17, "editor.renderWhitespace": "boundary", "terminal.integrated.fontSize": 16, "editor.minimap.renderCharacters": false, "editor.minimap.scale": 2, "editor.minimap.showSlider": "always", "terminal.integrated.stickyScroll.enabled": true, }
|
VS Code 1.90 集成终端乱码是一个 bug,可以通过设置 terminal.integrated.shellIntegration.enabled
为 false
来解决。
便捷使用
工作台“资源管理器”选项卡的“时间线”(窗口左下角)功能十分有用,可以查看文件修改历史及修改时间,对比差异或恢复。
VS Code 里有许多有用的快捷键,比如 Ctrl+D 快速选中多个相同的文本。可以按 F1 或 Ctrl+Shift+P 打开命令面板,搜索你要执行的操作,可以查看或设置操作的快捷键。
%APPDATA%/Code/User/settings.json{ "editor.mouseWheelZoom": true, "editor.wordWrap": "on", "terminal.integrated.mouseWheelZoom": true, "workbench.editor.wrapTabs": true, }
|
丝滑动画
看起来更流畅了。
%APPDATA%/Code/User/settings.json{ "editor.cursorBlinking": "phase", "editor.cursorSmoothCaretAnimation": "on", "editor.smoothScrolling": true, "terminal.integrated.smoothScrolling": true, "workbench.list.smoothScrolling": true, }
|
项目优化
我十分理解未保存代码可能会丢失修改,但我依然不建议启用自动保存。一方面 VS Code 会保持未保存文件的编辑状态,另一方面,自动保存会影响以下体验:
- 使用带有热更新功能的插件(Live Server)、框架(Vite)时页面会频繁异常刷新。
- 无意识的键入文本会导致代码损坏。如果你之后关闭了窗口,那么做出的修改难以复原。
- 与保存时自动格式化功能冲突。相比于按格式化快捷键,按保存快捷键时自动格式化更方便,并且还能养成频繁保存的习惯。
%APPDATA%/Code/User/settings.json{ "editor.formatOnSave": true, "editor.formatOnType": true, "files.autoGuessEncoding": true, "C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: Chromium, IndentWidth: 4}", "clangd.fallbackFlags": [ "-I${workspaceFolder}", ], "git.autofetch": true, "git.enableSmartCommit": true, "git.confirmSync": false, }
|
杂项
这些项目可能会影响少数情况下的体验。
%APPDATA%/Code/User/settings.json{ "window.titleBarStyle": "custom", "settingsSync.ignoredExtensions": [ "ms-vscode.cpptools", "llvm-vs-code-extensions.vscode-clangd", ], "[markdown]": { "editor.fontSize": 21, "editor.cursorSurroundingLines": 5, }, "editor.inlayHints.enabled": "offUnlessPressed", }
|