vscode配置remote ssh
下载老版本的vscode
1. 安装插件
vscode配置remote ssh_Hello_wshuo的博客-CSDN博客_remote ssh vscode

设置界面 右键最左边tab栏:





主体: vscode
插件: Remote SSH
Linux主体: vscode-server
插件: C/C++, CMake, CMake Tools, CodeLLDB, Rainbow Brackets, vscode-proto3, SVN,LuaHelper(tencent), clangd, lua(sumneko)

虚拟化主体: multipass + linux发行版(比如ubuntu)
补充: multipass实例本地端口转发代理Proxy(自己写)
launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Server-Remote-9101",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/testHello_gdb",
"args": [],
"cwd": "${workspaceFolder}/build/",
"MIMode": "gdb",
"miDebuggerServerAddress": "192.168.157.133:9101",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"type": "lldb",
"request": "attach",
"name": "Attach-Srv",
"pid": "${command:pickMyProcess}"
},
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/testHello",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
#配置cmake
cd build
cmake ../
make
服务器上启动 gdbserver --remote-debug 0.0.0.0:9101 ./GateSrv
gdbserver --remote-debug 0.0.0.0:9101 --attach 682420

json文件一般要改的就下面这些

{
"type": "LuaHe lper-Debug",
" request": " launch",
“name": "LuaPanda-GameSrv" ,
" luaFileExtension": "lua" ,
”connectionPort': 8718 ,
CWd" :
! $ {workspaceFolder}/bin/ lua
"updateTips": true,
”pathCaseSensitivity": true,
”stopOnEntry": false,
" useCHook": false,
" autoPathMode": true ,
"logL .evel": 1,
"dist inguishSameNameFile: true
}
"name": "g++ - 生成和调试活动文件", // 配置名称,显示在启动配置下拉菜单中
"type": "cppdbg", //配置类型
"request": "launch", //请求配置类型
"program": "${workspaceFolder}/build/main", //代表的可执行文件的绝对路径
"args": [], //传递给程序的命令行参数
"stopAtEntry": false, //可选参数。如果为true,则调试程序应在目标的入口点处停止。如果床底了processId,则不起任何作用
"cwd": "${workspaceFolder}", //cd到工程的顶层目录
"environment": [], //要添加到程序中的环境变量{"name":"config","value":"Debug"}
"externalConsole": false, //true:启动控制台;false:在vscode的集成的控制台显示
"MIMode": "gdb", //调试方式
切换编译实例 ctrl + shift + p


svn 使用
1. update

2. 
VScode中使用svn常用简单操作_大脸胖柴的博客-CSDN博客_vscode怎么配置svn
vscode+svn的配置和简单使用_大蚂蚁2号的博客-CSDN博客_vscode svn
{
// Whether auto refreshing is enabled
"svn.autorefresh": true,
// Select all files when commit changes
"svn.commit.changes.selectedAll": true,
// Check empty message before commit
"svn.commit.checkEmptyMessage": true,
// Set file to status resolved after fix conflicts
"svn.conflicts.autoResolve": false,
// Encoding of svn output if the output is not utf-8. When this parameter is null, the encoding is automatically detected. Example: 'windows-1252'.
"svn.default.encoding": null,
// The default location to checkout a svn repository.
"svn.defaultCheckoutDirectory": "",
// When a file is deleted, what SVN should do? `none` - Do nothing, `prompt` - Ask the action, `remove` - automatically remove from SVN
"svn.delete.actionForDeletedFiles": "prompt" // values: ["none","prompt","remove"],
// Ignored files/rules for `svn.delete.actionForDeletedFiles`(Ex.: file.txt or **/*.txt)
"svn.delete.ignoredRulesForDeletedFiles": [],
// Controls whether to automatically detect svn externals.
"svn.detectExternals": true,
// Controls whether to automatically detect svn on ignored folders.
"svn.detectIgnored": true,
// Show diff changes using latest revision in the repository. Set false to use latest revision in local folder
"svn.diff.withHead": true,
// Whether svn is enabled
"svn.enabled": true,
// Try the experimental encoding detection
"svn.experimental.detect_encoding": null,
// Priority of encoding
"svn.experimental.encoding_priority": [],
// Url for the gravitar icon using the <AUTHOR>, <AUTHOR_MD5> and <SIZE> placeholders
"svn.gravatar.icon_url": "https://www.gravatar.com/avatar/<AUTHOR_MD5>.jpg?s=<SIZE>&d=robohash",
// Use garavatar icons in log viewers
"svn.gravatars.enabled": true,
// Ignores the warning when SVN is missing
"svn.ignoreMissingSvnWarning": null,
// List of SVN repositories to ignore.
"svn.ignoreRepositories": null,
// Ignores the warning when working copy is too old
"svn.ignoreWorkingCopyIsTooOld": null,
// Regex to detect path for 'branches' in SVN URL, 'null' to disable. Subpath use 'branches/[^/]+/([^/]+)(/.*)?' (Ex.: 'branches/...', 'versions/...')
"svn.layout.branchesRegex": "branches/([^/]+)(/.*)?",
// Regex group position for name of branch
"svn.layout.branchesRegexName": 1,
// Set true to show 'branches/<name>' and false to show only '<name>'
"svn.layout.showFullName": true,
// Regex group position for name of tag
"svn.layout.tagRegexName": 1,
// Regex to detect path for 'tags' in SVN URL, 'null' to disable. Subpath use 'tags/[^/]+/([^/]+)(/.*)?'. (Ex.: 'tags/...', 'stamps/...')
"svn.layout.tagsRegex": "tags/([^/]+)(/.*)?",
// Regex to detect path for 'trunk' in SVN URL, 'null' to disable. (Ex.: '(trunk)', '(main)')
"svn.layout.trunkRegex": "(trunk)(/.*)?",
// Regex group position for name of trunk
"svn.layout.trunkRegexName": 1,
// Number of commit messages to log
"svn.log.length": 50,
// Maximum depth to find subfolders using SVN
"svn.multipleFolders.depth": 4,
// Allow to find subfolders using SVN
"svn.multipleFolders.enabled": null,
// Folders to ignore using SVN
"svn.multipleFolders.ignore": ["**/.git","**/.hg","**/vendor","**/node_modules"],
// Path to the svn executable
"svn.path": "/usr/bin/svn",
// Only show previous commits for a given user. Requires svn >= 1.8
"svn.previousCommitsUser": null,
// Refresh remote changes on refresh command
"svn.refresh.remoteChanges": null,
// Set the interval in seconds to check changed files on remote repository and show in statusbar. 0 to disable
"svn.remoteChanges.checkFrequency": 300,
// Show the output window when the extension starts
"svn.showOutput": null,
// Show the update message when update is run
"svn.showUpdateMessage": true,
// Set left click functionality on changes resource state
"svn.sourceControl.changesLeftClick": "open diff" // values: ["open","open diff"],
// Combine the svn external in the main if is from the same server.
"svn.sourceControl.combineExternalIfSameServer": false,
// Allow to count unversioned files in status count
"svn.sourceControl.countUnversioned": true,
// Hide unversioned files in Source Control UI
"svn.sourceControl.hideUnversioned": false,
// Ignore unversioned files like .gitignore, Configuring this will overlook the default ignore rule
"svn.sourceControl.ignore": [],
// Changelists to ignore on commit
"svn.sourceControl.ignoreOnCommit": ["ignore-on-commit"],
// Changelists to ignore on status count
"svn.sourceControl.ignoreOnStatusCount": ["ignore-on-commit"],
// Set to ignore externals definitions on update (add --ignore-externals)
"svn.update.ignoreExternals": true
}
使用idea 的快捷键 clion 的快捷键, 安装这个

修改编译的时候使用cpu核数

7. 搜索排除 ,在settings.json 中
"search.exclude": {
"**/build": true,
"**/runtime": true,
"**/proto": true,
"**/client": true,
}
8. 缓存占用过大的问题.
关闭预编译头文件功能
步骤1
关闭vscode
删除“项目\ .vscode \ ipch“文件夹
注意:该文件夹包含缓存的预编译头文件(PCH)。
步骤2
打开vscode,按住ctrl+shift+P键,在弹框中搜索settings,然后打开settings.json配置文件
将下面这些C ++设置添加到settings.json以禁用创建/使用PCH并确保IntelliSense不会回退到标记解析器。
"C_Cpp.intelliSenseCacheSize": 0,
"C_Cpp.intelliSenseEngineFallback": "Disabled"
解决格式化失效
我使用vscode的格式插件Clang-Format时,在配置均正确的情况下,无法格式化代码的bug,重启电脑,重启vscode,重装vscode均没有解决该问题,后来尝试使用上面禁用预编译头文件(PCH)后,终于可以正常使用了
vscode 优化.vscode/ipch(解决格式化失效以及占用存储空间大的问题)_vscode ipch-CSDN博客
// 自动作者
1.安装vscode-fileheader
2.Ctrl+,打开设置

/* * @Author: {author} * @Date: {createTime} */
Ctrl+Alt+I 产生信息
"fileheader.tpl": "/*\r\n * @Author: {author} \r\n * @Date: {createTime} \r\n */\r\n"
或者


忽略.meta文件
使用快捷键 Ctrl + ,
在 “Settings” 界面,你会看到一个搜索框。在搜索框中输入 “files.exclude”,这会显示与文件过滤相关的设置。

配置两个空格缩进

关闭所有语言的灰色提示
.vscode/settings.json
"editor.inlayHints.enabled": "off"

清除缓存,删除缓存
方法一:删除 .vscode 文件夹
- 在每个副本的项目根目录下,删除
.vscode文件夹(里面保存了本地的设置和部分缓存)。 - 关闭 VSCode,然后重新打开只包含你需要的副本的文件夹。
方法二:删除全局缓存
VSCode 的全局缓存路径因操作系统不同而异:
- Windows:
C:\Users\<你的用户名>\AppData\Roaming\Code\ - macOS:
~/Library/Application Support/Code/ - Linux:
~/.config/Code/
你可以尝试关闭 VSCode,然后删除(或重命名)上述路径下的 Cache、CachedData、User/workspaceStorage 目录。
Ctrl + Shift + P
Clear Recently Opened
File: Clear Recently Opened
9. 条件断点
<1> 右键红点

<2> 编辑条件 比如: score == 100
x > 50 && y < 10

<3> 回车,开始跑吧
10. watch 功能使用
<1> 先进入函数 ,断点暂停了

<2> 添加表达式并且回车

<3> 
<4> 改变后 可以看到修改


cmake ,选择build 目标

cmake 配置编译线程数: settings.json 添加
"cmake.parallelJobs": 4
=========================visual stido 配置===========
1.文件光标自动跟随
- 点击顶部菜单栏的 "工具"(Tools)。25
- 在下拉菜单中选择 "选项"(Options)。56
- 在 "选项" 窗口中:
- 左侧导航树选择 "项目和解决方案"(Projects and Solutions)。15
- 在右侧面板的 "常规"(General)部分,找到并勾选 "在解决方案资源管理器中跟踪活动项"(Track Active Item in Solution Explorer)。12
- 点击 "确定" 保存设置。之后,当打开或切换文件时,解决方案资源管理器会自动滚动并高亮对应

vs2019 垂直拆分

vs2022 ,拖动到这里拆分

===============vscode run vs工程===========================================
1.安装了c# ,vscode-solution-exploer ,一大堆.c++工具
2. launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "附加到进程",
"type": "cppvsdbg",
"request": "attach",
"processId": "${command:pickProcess}"
},
{
"name": "game",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/Debug/gameserver/gameserver.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/Debug/gameserver",
"environment": [],
"externalConsole": true
},
{
"name": "databases",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/Debug/databaseserver/databaseserver.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/Debug/databaseserver",
"environment": [],
"externalConsole": true
},
{
"name": "login",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/Debug/loginserver/loginserver.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/Debug/loginserver",
"environment": [],
"externalConsole": true
},
{
"name": "dispatch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/Debug/dispatcherserver/dispatcherserver.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/Debug/dispatcherserver",
"environment": [],
"externalConsole": true
},
{
"name": "user",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/Debug/userserver/userserver.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/Debug/userserver",
"environment": [],
"externalConsole": true
},
{
"name": "local",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/Debug/localuserserver/localuserserver.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/Debug/localuserserver",
"environment": [],
"externalConsole": true
},
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/Users/IGG/game/server/code/src/game/dispatcherserver/src",
"program": "c:/Users/IGG/game/server/code/src/game/dispatcherserver/src/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
3.task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build with MSBuild",
"type": "shell",
"command": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe",
"args": [
"${workspaceFolder}/server.sln",
"/p:Configuration=Debug",
"/p:Platform=x64"
],
"group": { "kind": "build", "isDefault": true },
"problemMatcher": "$msCompile"
}
]
}
然后按 Ctrl+Shift+B 运行编译任务。


4.c_cpp_protej.json
{
"configurations": [
{
"name": "Win64-MSVC",
"compilerPath": "D:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe",
"intelliSenseMode": "windows-msvc-x64",
"cppStandard": "c++20",
"cStandard": "c17",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
]
}
],
"version": 4
}
"C_Cpp.intelliSenseEngine": "disabled"→ 改成"default"—— 把微软 C/C++ 引擎重新打开,这是关键。- 顺手删了 clangd 残留的两行配置(
clangd.path、clangd.detectExtensionConflicts),clangd 都卸了,留着是垃圾。 - 上面改的都是setting.json
========================修改本目录下的编码========================
-
在 VS Code 里打开你的工程文件夹。
-
按
Ctrl+Shift+P打开命令面板,输入Preferences: Open Workspace Settings (JSON)(中文版:首选项: 打开工作区设置(JSON))。 -
在弹出的
settings.json中添加以下内容:
{
"files.encoding": "utf8",
"files.autoGuessEncoding": false
}更多推荐


所有评论(0)