Visual Studio Code

简介

https://code.visualstudio.com

安装配置

通用下载链接:

1
2
https://vscode.cdn.azure.cn/stable/{ID}/vscode-server-linux-x64.tar.gz
https://vscode.cdn.azure.cn/stable/{ID}/VSCodeUserSetup-x64-1.65.2.exe

找到下载链接:ps aux | grep wget
可以看到:wget --tries=0 --connect-timeout=7 --dns-timeout=7 --show-progress -nv -O vscode-server.tar.gz http://update.code.visualstudio.com/commit:b3318bc0524af3d74034b8bb8a64df0ccf35549a/server-linux-x64/stable

找到真正的下载地址,主要是找到 commit id

wget --tries=0 --connect-timeout=7 --dns-timeout=7 --show-progress -O vscode-server.tar.gz http://update.code.visualstudio.com/commit:b3318bc0524af3d74034b8bb8a64df0ccf35549a/server-linux-x64/stable

URL transformed to HTTPS due to an HSTS policy
–2021-11-08 15:57:26– https://update.code.visualstudio.com/commit:b3318bc0524af3d74034b8bb8a64df0ccf35549a/server-linux-x64/stable
Resolving update.code.visualstudio.com (update.code.visualstudio.com)… 20.43.132.130
Connecting to update.code.visualstudio.com (update.code.visualstudio.com)|20.43.132.130|:443… connected.
HTTP request sent, awaiting response… 302 Found
Location: https://az764295.vo.msecnd.net/stable/b3318bc0524af3d74034b8bb8a64df0ccf35549a/vscode-server-linux-x64.tar.gz [following]
–2021-11-08 15:57:26– https://az764295.vo.msecnd.net/stable/b3318bc0524af3d74034b8bb8a64df0ccf35549a/vscode-server-linux-x64.tar.gz
Resolving az764295.vo.msecnd.net (az764295.vo.msecnd.net)… 117.18.232.200
Connecting to az764295.vo.msecnd.net (az764295.vo.msecnd.net)|117.18.232.200|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 53650674 (51M) [application/gzip]
Saving to: ‘vscode-server.tar.gz’

使用 vscode.cdn.azure.cn 取代 az764295.vo.msecnd.net

将下载的文件放入~/.vscode-server/bin/b3318bc0524af3d74034b8bb8a64df0ccf35549a

解压tar xf vscode-server.tar.gz

移动一级目录到上层mv vscode-server-linux-x64/* .

编译调试

1
2
3
4
5
6
7
8
9
// settings.json
{
"cmake.configureEnvironment": {
"CMAKE_PREFIX_PATH": "C:/Qt/6.6.2/msvc2019_64"
},
"cmake.debugConfig": {
"args": ["-i", "a"]
}
}
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
// launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/aaa",
"args": ["-i", "a"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"sourceFileMap": {
"${workspace}/bbb": ".",
"${workspace}/ccc": "."
},
"coreDumpPath": ""
}
]
}
1
// tasks.json

使用 SSH 进行远程开发

Visual Studio Code 通过远程开发插件可以将 container,远程计算机或 Windows Linux 子系统(WSL)用作完整的开发环境。

arch

首先安装插件:

extensions-remote

在 VS Code 中,从命令面板(F1)中选择“ Remote-SSH:Connect to Host … ”,在窗口中运行以下命令并适当替换“ user@hostname ”来验证您可以连接到 SSH 主机:

Illustration of user@host input box

如果 VS Code 无法自动检测到要连接的服务器的类型,就需要手动选择类型:

Illustration of platform selection

选择平台后,它将被存储在 remote.SSH.remotePlatform 属性下的 VSCode 设置中,因此你可以随时更改它。
稍后,VS Code 将连接到 SSH 服务器并进行自我设置。VS Code 将使用进度通知显示最新状态,并且可以在 Remote-SSH 输出通道中查看详细的日志。
你可以打开远程机器上的任何文件夹或工作区通过“ File > Open… or File > Open Workspace… ”,就像在本地打开一样。

File Open on a remote SSH host

extensions-cmake

status

在扩展商店里安装 CMake 插件后,就可以直接通过点击 VSCode 状态栏中的图标编译或者调试工程。

参考文献


Visual Studio Code
https://laplac2.github.io/tools/vscode/
作者
Laplace
发布于
2023年3月12日
许可协议