VScode相关设置

该博客围绕VSCode展开,介绍了插件、快捷键和代码规范相关内容。插件方面,涵盖C/C++编写调试、图标显示、括号着色等多种插件,还提及离线安装和远程服务器安装方法;快捷键部分给出代码编辑、git提交等操作的相关链接;代码规范涉及推荐设置、自定义代码段等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一 插件:

1.windows下使用vscode编写运行以及调试C/C++

2.vscode-icons:VsCode插件之vscode-icons_天马3798-优快云博客_vscode图标插件  vscode-icons-team.vscode-icons-8.1.0.vsix

Bookmarks: 标记,寻找代码。左侧有直通车,右键菜单里面 
Rainbow Brackets:为圆括号,方括号和大括号提供彩虹色
Bracket Pair Colorizer:用于着色匹配括号
Project Manager:它可以帮助您轻松访问项目
GitLens:git日志查看插件https://marketplace.visualstudio.com/_apis/public/gallery/publishers/eamodio/vsextensions/gitlens/8.3.0/vspackage
高亮选中:  highlight-icemode   iceliu.highlight-icemode-0.0.6.vsix
TODO颜色显示:better comments  aaron-bond.better-comments-2.0.5.vsix
window使用ssh: 【宇宙最强编辑器VS Code】(十)使用VS Code + SSH进行远程开发_Mculover666的博客(嵌入式)-优快云博客_ssh 远程编辑器

免输密码:把window的id_rsa.pub>>authorized_keys,剪切到远程服务器,重启vscode即可。添加好私钥:

IdentityFile "C:\Users\user_name\.ssh\id_rsa",域名要对

远程服务器安装vscode插件:就是把window里面的.vscode插件压缩成.zip格式,然后放到
服务器上.vscode/extension里面解压,注意c++插件有版本区分。

早上可以下载.vsix文件:
尝试下载离线安装到远程服务器,然后安装。
powerTools:  用于log排序。

1.离线安装
下载历史版本。https://www.okcode.net/article/59181
离线安装
vscode C/C++安装依赖问题,手动找到packet.jason文件, 从里面的url拷贝linux版本即可
esbenp.prettier-vscode-2.2.0.vsix
HookyQR.beautify-1.1.0.vsix
ms-vscode.cpptools-0.17.6.vsix
java跳转需要装redhat.java-0.64.1.vsix,并设置对应openjdk环境,
务器手动安装vscode server

二 快捷键:

5.代码想要同时编辑多处:https://www.jb51.net/softjc/609020.html

[快捷键]vscode: Visual Studio Code 常用快捷键 - 魚魚 - 博客园

[清除空行]vscode 清除多余空行_二等碗-优快云博客_vscode 删除空行

6.使用git提交:vscode使用git - 知乎

7.手动更新vscode
8.完全卸载:$sudo apt-get purge code;$cd ~ && rm -rf .vscode && rm -rf .config/Code

三 代码规范

1.24.1推荐设置:

{
    "remote.SSH.showLoginTerminal": true,
    "remote.SSH.remotePlatform": {
        "SZHVM00454.apac.bosch.com": "linux",
        "huyilang": "linux",
        "10.173.252.121": "linux",
        "sghvm011034-vm.sgh.apac.bosch.com": "linux",
        "SGHKVM0010": "linux",
        "SZHVM00454": "linux"
    },
    "workbench.iconTheme": "vscode-icons",
    "vsicons.dontShowNewVersionMessage": true,
    "bracketPairColorizer.depreciation-notice": false,
    "editor.snippetSuggestions": "top",
    "editor.tabCompletion": "on",
    "editor.formatOnSave": false,
    "editor.formatOnType": true,
    "editor.formatOnPaste": true,
    "editor.renderWhitespace": "all",
    "editor.insertSpaces": true,
    "editor.wrappingIndent": "same",
    "editor.trimAutoWhitespace": false,
    "files.trimTrailingWhitespace": true,
    "files.autoSave": "onFocusChange",
    "editor.scrollBeyondLastLine": false,
    "editor.tabSize": 4,
    "editor.wordWrap": "on",
"files.insertFinalNewline": true,
    "editor.acceptSuggestionOnCommitCharacter": true,
    "editor.acceptSuggestionOnEnter": "smart",
    "editor.autoIndent": "full",
    "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": true
    },
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true
    },
    "explorer.confirmDelete": false,
    "search.followSymlinks": false,
    "javascript.format.enable": true,
    "javascript.format.insertSpaceAfterConstructor": true,
    "javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": true,
    "emmet.showSuggestionsAsSnippets": true,
    "json.format.enable": true,
    "typescript.format.enable": true,
    "C_Cpp.intelliSenseEngineFallback": "enabled",
    "C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: WebKit, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Linux, MaxEmptyLinesToKeep: 1, BreakBeforeBraces: Allman, AlignAfterOpenBracket: true, IndentCaseLabels: true, NamespaceIndentation: None, AllowShortFunctionsOnASingleLine: None, KeepEmptyLinesAtTheStartOfBlocks: false, PointerAlignment: Right, AlignTrailingComments: true, SpacesBeforeTrailingComments: 4, ColumnLimit: 100}",
    "C_Cpp.clang_format_style": "{BasedOnStyle: WebKit, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Linux, MaxEmptyLinesToKeep: 1, BreakBeforeBraces: Allman, IndentCaseLabels: true, AlignAfterOpenBracket: true, NamespaceIndentation: None, AllowShortFunctionsOnASingleLine: None, KeepEmptyLinesAtTheStartOfBlocks: false, PointerAlignment: Right, AlignTrailingComments: true, SpacesBeforeTrailingComments: 4, ColumnLimit: 100}",
    "highlight-icemode.backgroundColor": "none",
    "highlight-icemode.borderColor": "#c5293e",
    "update.mode": "none",
    "extensions.autoUpdate": false,
    "extensions.autoCheckUpdates": false,
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "restructuredtext.updateOnTextChanged": "false",
    "python.pythonPath": "/usr/bin/python3.8",
    "security.workspace.trust.untrustedFiles": "open",
    "diffEditor.ignoreTrimWhitespace": false,
    "git.path": "/usr/bin/git",
    "DockerRun.DisableAutoGenerateConfig": true,
    "extensions.ignoreRecommendations": true,
    "files.autoSave": "afterDelay",
    "cmake.configureOnOpen": true,
    "window.zoomLevel": -1,
    "editor.parameterHints": false,
    "editor.wordBasedSuggestions": false,
    "editor.suggestSelection": "recentlyUsed",
    "editor.cursorSmoothCaretAnimation": true,
    "workbench.list.smoothScrolling": true,
    "editor.smoothScrolling": true,
    "editor.cursorBlinking": "smooth",
    "editor.mouseWheelZoom": true,
}

2.2.自定义代码段 

设置:File->preferences->用户代码片段->新建全局代码片段文件
版本,不用.开头,推荐用字母开头。

全面教程: [VS Code]跟我一起在Visual Studio Code 添加自定义snippet(代码段),附详细配置_狼行天下-优快云博客

头注释:http://www.chensuyang.com/index.php/archives/345

2.3.使用find all reference

让VSCode支持 "Find all reference"_Empkin的专栏-优快云博客_reference vscode

sudo apt-get install global

gtags

2.4.error:Visual Studio Code is unable to watch for file changes in this large workspace

https://zhuanlan.zhihu.com/p/37819698?utm_source=wechat_session&utm_medium=social&utm_oi=812025187762589696

<think>我们正在讨论如何在VSCode中配置设置。根据引用,配置VSCode设置有两种主要方式:通过图形界面(设置UI)或直接编辑settings.json文件。用户可以根据自己的偏好选择其中一种方法。引用[2]提到可以通过修改用户设置或工作区设置来配置VSCode。用户设置是全局的,而工作区设置仅针对当前项目。引用[3]展示了一个settings.json文件的示例,其中包含了一些常见的配置选项,如自动保存、启用缩略图、ESLint集成等。因此,我将分步骤说明如何配置VSCode设置,包括两种方法。步骤1:打开设置方法一(图形界面):1.打开VSCode。2.使用快捷键`Ctrl+,`(Windows/Linux)或`Cmd+ ,`(Mac)打开设置界面。3.或者,点击左下角的齿轮图标(管理)->设置。方法二(直接编辑settings.json):1.在设置界面右上角有一个打开设置(JSON)的图标(一个带有{}的图标),点击即可打开settings.json文件。2.或者,使用快捷键 `Ctrl +Shift +P`(Windows/Linux)或`Cmd+ Shift+ P`(Mac)打开命令面板,输入“Preferences:Open Settings(JSON)”并选择。步骤2:修改设置在图形界面中,你可以搜索设置项并选择或输入值。在settings.json中,你可以直接添加或修改JSON格式的键值对。步骤3:保存设置在图形界面中,修改后自动保存。在settings.json中,保存文件(Ctrl+S)后设置立即生效。引用[3]中的示例settings.json包含了一些常见设置,例如:-自动保存:`"files.autoSave":"afterDelay"`-启用缩略图:`"editor.minimap.enabled": true`-使用ESLint自动修复:`"editor.codeActionsOnSave":{ "source.fixAll.eslint": true}`等用户可以根据需要添加或修改这些设置。注意事项:-在settings.json中,注释使用`//`,但注意JSON标准不支持注释,VSCode允许在settings.json中使用注释,但严格JSON不允许。因此,如果复制到其他地方,注释可能导致错误。-工作区设置会覆盖用户设置,项目中的.vscode/settings.json文件用于工作区设置。根据引用[1],VSCode的突出特点是其强大的插件功能,用户可以根据需要安装插件来扩展功能,每个用户的VSCode都是高度个性化的。因此,配置设置是定制VSCode的重要部分。相关问题:1.如何为特定语言(如Python、C++)配置VSCode设置?2.如何在VSCode中管理工作区设置?3.VSCode有哪些常用的设置项可以提高开发效率?注意:在回答中,我们引用了提供的引用[1]、[2]、[3],并在末尾添加了引用标识。</think>### VSCode 配置设置指南 在 VSCode 中配置设置主要有两种方式,用户可根据需求选择: #### 方法一:图形化界面设置(推荐初学者) 1. **打开设置面板** - 快捷键:`Ctrl + ,`(Windows/Linux)或 `Cmd + ,`(Mac) - 菜单路径:左下角齿轮图标 → 设置 2. **修改设置** - 在搜索框输入关键词(如 `font size`) - 通过下拉菜单/输入框直接修改值 - 设置自动实时生效[^1] #### 方法二:直接编辑 settings.json(高级用户) 1. **打开配置文件** - 命令面板(`Ctrl+Shift+P`)输入:`Preferences: Open Settings (JSON)` - 或点击设置界面右上角的 `{}` 图标 2. **修改 JSON 格式配置** ```json { // 字体设置 "editor.fontSize": 16, "editor.fontFamily": "Consolas, 'Courier New', monospace", // 自动保存(修改后延迟保存) "files.autoSave": "afterDelay", // 启用代码缩略图 "editor.minimap.enabled": true, // ESLint 自动修复 "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, // 排除特定文件/文件夹 "files.exclude": { "**/.git": true, "**/.vscode": true, "**/node_modules": true } } ``` > 保存文件(`Ctrl+S`)后立即生效[^3] #### 常用配置示例 1. **界面优化**: ```json "workbench.colorTheme": "Default Dark+", "window.titleBarStyle": "custom", "editor.renderWhitespace": "all" ``` 2. **代码辅助**: ```json "editor.formatOnSave": true, "editor.suggestSelection": "first", "emmet.triggerExpansionOnTab": true ``` 3. **文件管理**: ```json "explorer.confirmDelete": false, "files.autoSaveDelay": 1000 // 自动保存延时(毫秒) ``` #### 配置层级说明 | 配置类型 | 存储位置 | 优先级 | |----------------|------------------------------|--------| | **用户设置** | `%APPDATA%/Code/User/settings.json` | 低 | | **工作区设置** | 项目内 `.vscode/settings.json` | 高 | | **远程设置** | 容器/远程开发环境配置 | 最高 | > 工作区设置会覆盖用户设置,适合项目特定的配置[^2] #### 注意事项 1. JSON 文件需严格遵循语法规范(引号、逗号等) 2. 修改后若出现异常,可通过命令面板运行 `Preferences: Reset Settings` 3. 安装扩展后,部分设置项可能需要重启生效 通过个性化配置,您可以将 VSCode 打造成专属的高效开发环境[^1]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值