发布于 2026-01-06 2 阅读
0

VSCode - 必备功能 多设备 字体扩展 无需设置 键盘快捷键 亲爱的圣诞老人 一枚戒指统御众戒! 特别提及 奖励曲目:

VSCode - 基本要素

多台设备

字体

扩展

不需要

设置

键盘快捷键

亲爱的圣诞老人

一枚戒指,统御众戒!

特别提及

奖励曲目:

⚠ 已过时:VSCode 现在支持配置文件

“你必须拥有……”这是很多关于 Visual Studio Code 扩展的帖子和视频的主要标题,目的是为了吸引更多关注,但这个编辑器就像一只变色龙,可以随心所欲地改变自己的环境,这就是为什么你需要创建自己的配方

这些想法都很主观。我打算分享一下我的通用配置,希望有人能从中获得一些有用的信息。

建议先阅读有关Visual Studio Code 设置的内容,以了解用户设置和工作区设置之间的区别。

多台设备

开始之前,强烈建议安装并设置Settings Sync扩展程序。它能将您的设置和扩展程序备份到云端,并使用私有 gist 存储这些文件。

它会同步所有扩展程序和包含以下内容的完整用户文件夹:

  1. 设置文件
  2. 按键绑定文件
  3. 启动文件
  4. 代码片段文件夹
  5. VSCode 扩展和扩展配置
  6. 工作区文件夹

这样您就可以同步您的设备,而无需浪费时间进行恢复出厂设置或购买新设备。

字体

Victor Mono 是一款开源等宽字体,带有可选的半连接斜体和编程符号连字。

{
    "editor.fontFamily": "'Victor Mono', Consolas, 'Courier New', monospace",
    "editor.fontLigatures": true
}
Enter fullscreen mode Exit fullscreen mode
settings.json

扩展

编辑

{
    "bookmarks.saveBookmarksInProject": true,
    "bookmarks.navigateThroughAllFiles": true,
}
Enter fullscreen mode Exit fullscreen mode
settings.json
{
    "fileNestingUpdater.autoUpdate": true,
    "fileNestingUpdater.autoUpdateInterval": 720,
    "fileNestingUpdater.promptOnAutoUpdate": true,
    "fileNestingUpdater.upstreamRepo": "antfu/vscode-file-nesting-config",
    "fileNestingUpdater.upstreamBranch": "main"
}
Enter fullscreen mode Exit fullscreen mode
settings.json
{
    "filesize.showGzipInStatusBar": true
}
Enter fullscreen mode Exit fullscreen mode
settings.json
{
    "gremlins.showInProblemPane": true
}
Enter fullscreen mode Exit fullscreen mode
settings.json
{
    "gutterpreview.sourceFolder": "public"
}
Enter fullscreen mode Exit fullscreen mode
settings.json

比较

包裹

衬垫

{
    "cSpell.language": "en,es"
}
Enter fullscreen mode Exit fullscreen mode
settings.json
{
    "[markdown]": {
        "editor.formatOnSave": false,
        "editor.quickSuggestions": {
            "comments": "on",
            "strings": "on",
            "other": "on"
        },
        "editor.tabSize": 2,
        "files.trimTrailingWhitespace": false,
    },
    "markdownlint.config": {
        "MD024": { "siblings_only": true }
    }
}
Enter fullscreen mode Exit fullscreen mode
settings.json

休息

结对编程

主题

{
    "workbench.iconTheme": "material-icon-theme"
}
Enter fullscreen mode Exit fullscreen mode
settings.json

版本控制


不需要

有很多扩展程序毫无用处,完全可以通过一些 VSCode 配置来实现相同的功能。


设置

在每个项目中,将通用设置(用户设置)与特定用途设置(工作区设置)相结合。

{
    "breadcrumbs.enabled": true,
    "diffEditor.ignoreTrimWhitespace": true,
    "editor.autoIndent": "full",
    "editor.bracketPairColorization.enabled": true,
    "editor.guides.bracketPairs": true,
    "editor.codeActionsOnSave": {
        "source.organizeImports": false
    },
    "editor.cursorBlinking": "expand",
    "editor.formatOnPaste": false,
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "editor.letterSpacing": 1,
    "editor.minimap.enabled": false,
    "editor.linkedEditing": true,
    "editor.renderWhitespace": "boundary",
    "editor.rulers": [80, 120],
    "editor.snippetSuggestions": "top",
    "editor.stickyScroll.enabled": true,
    "editor.suggest.preview": true,
    "editor.tabCompletion": "on",
    "editor.unicodeHighlight.ambiguousCharacters": true,
    "editor.unicodeHighlight.invisibleCharacters": true,
    "editor.wordWrap": "off",
    "explorer.autoReveal": true,
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true
    },
    "files.trimTrailingWhitespace": true,
    "git.autofetch": true,
    "git.alwaysShowStagedChangesResourceGroup": true,
    "git.mergeEditor": true,
    "git.suggestSmartCommit": false,
    "merge-conflict.diffViewPosition": "Below",
    "search.exclude": {
        "**/build": true,
        "**/coverage": true,
        "**/dist": true
    },
    "search.showLineNumbers":true,
    "screencastMode.onlyKeyboardShortcuts":true,
    "terminal.integrated.fontFamily": "MesloLGS NF",
    "terminal.integrated.fontSize": 12,
    "terminal.integrated.shellIntegration.enabled": true,
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "terminal.integrated.defaultProfile.osx": "iTerm.app",
    "window.openWithoutArgumentsInNewWindow": "on",
    "window.menuBarVisibility": "compact",
    "window.commandCenter": true,
    "workbench.editor.highlightModifiedTabs": true,
    "workbench.editor.decorations.colors": true,
    "workbench.editor.decorations.badges": true,
    "workbench.settings.editor": "json",
    "workbench.startupEditor": "none",
    "workbench.tree.renderIndentGuides": "none",
    "[json][jsonc]": {
        "editor.defaultFormatter": "vscode.json-language-features",
        "editor.formatOnSave": true,
        "editor.tabSize": 4,
    },
    "[yaml]": {
        "editor.formatOnSave": false,
        "editor.tabSize": 2,
        "files.trimTrailingWhitespace": false
    },
}
Enter fullscreen mode Exit fullscreen mode
settings.json

键盘快捷键

[
    // Wrap Emmet
    {
        "key": "ctrl+shift+w", //cmd+w on mac
        "command": "editor.emmet.action.wrapWithAbbreviation",
        "when": "editorHasSelection",
    },
    // Comments
    {
        "key": "ctrl+numpad_divide",
        "command": "editor.action.commentLine",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+/",
        "command": "editor.action.commentLine",
        "when": "editorTextFocus && !editorReadonly"
    },
]
Enter fullscreen mode Exit fullscreen mode
keybinding.json

亲爱的圣诞老人

这款出色的编辑器我只缺少一个功能,那就是能够在不同的环境之间切换,并且即使不需要所有工具,也不必加载它们。

实际上,你可以手动在每个项目中禁用它,但将来最好能够切换环境并关闭不需要的扩展。

在 VSCode 团队解决这个问题之前,我们可以使用创建不同版本的变通方法:ReactNode.js.NetArduino

dock-macos

一枚戒指,统御众戒!

您可以让团队使用相同的设置,只需将其保存为settings.json文件,并将扩展名也保存为extensions.json文件,两者都放在.vscode文件夹内即可。

然后,当有人克隆/拉取存储库时,您的 Code 用户设置将用工作区设置覆盖,并显示推荐的扩展。

特别提及

{
    "powermode.combo.location": "off",
    "powermode.enabled": true,
    "powermode.explosions.duration": 300,
    "powermode.explosions.size": 5,
    "powermode.shake.enabled": false,
}
Enter fullscreen mode Exit fullscreen mode
settings.json

无需慌乱的现场演示?是的……轻松简单,就像日本人一样!

奖励曲目:

强烈推荐访问https://vscodecandothat.com/,这是一个学习实用代码技巧的好资源。另外,也请关注一下Live Share扩展程序。

进入菜单Help > Interactive Playground,您可以通过简短的演示体验编辑器的基本功能。


就这些啦!祝大家
编程愉快
! 🖖

啤酒

文章来源:https://dev.to/equiman/my-essential-visual-studio-code-extensions-and-configurations-5197