一、前言
- 据说是宇宙第一IDE,反正vim搞不定的我就用vscode
二、下载加速
- 将下载链接的地址替换为国内镜像地址
vscode.cdn.azure.cn
即可
三、好用的插件
1. 跨平台快捷键不一致
- 在windows上使用习惯的快捷键在linux不适用
- 安装一个
windows default keybinding
就好了
2. 16进制查看文件
3. cmake
CMake
: cmake语言支持CMake Tools
: vscode界面的cmake工具
踩坑记
- 安装了新的gcc,scan之后没有更新
- 删除
/home/sangfor/.local/share/CMakeTools/cmake-tools-kits.json
的内容,重新扫描即可
3. remote-ssh
3.1. 服务端组件离线下载地址
- linux:
https://update.code.visualstudio.com/commit:<commit_id>/server-linux-x64/stable
- windows:
https://update.code.visualstudio.com/commit:<commit_id>/server-win32-x64/stable
4. Draw.io 画图插件
5. vscode-mindmap 思维导图
四、code-server web版vscode
- 这个东西对付没有界面的服务器又不想在本地安装vscode的很好用
1. 安装
- 直接下载release包运行即可,地址
- archlinux可以使用
yay
进行安装
2. 配置
- linux配置文件在
~/.config/code-server/config.yaml
- 默认仅提供
127.0.0.1
的访问,想要外部访问需要配置bind-addr
为0.0.0.0:8080
3. 使用nginx进行转发,websocket失败导致无法使用
4. arm上安装后无法使用
报错如下
1
| Cannot find module '@node-rs/argon2-linux-arm64-gnu'
|
解决办法
- 下载
https://registry.yarnpkg.com/@node-rs/argon2-linux-arm64-gnu/-/argon2-linux-arm64-gnu-1.1.0.tgz
- 解压替换到
/usr/lib/code-server/node_modules/@node-rs/argon2-linux-arm64-gnu
即可
5. 无法选中粘贴
- web版限制了http访问的部分粘贴功能,需要开启https访问即可
五、调试配置 launch.json
json中可用的内置变量
${workspaceFolder}
- the path of the folder opened in VS Code
${workspaceFolderBasename}
- the name of the folder opened in VS Code without any slashes (/)
${file}
- the current opened file
${fileWorkspaceFolder}
- the current opened file’s workspace folder
${relativeFile}
- the current opened file relative to workspaceFolder
${relativeFileDirname}
- the current opened file’s dirname relative to workspaceFolder
${fileBasename}
- the current opened file’s basename
${fileBasenameNoExtension}
- the current opened file’s basename with no file extension
${fileDirname}
- the current opened file’s dirname
${fileExtname}
- the current opened file’s extension
${cwd}
- the task runner’s current working directory upon the startup of VS Code
${lineNumber}
- the current selected line number in the active file
${selectedText}
- the current selected text in the active file
${execPath}
- the path to the running VS Code executable
${defaultBuildTask}
- the name of the default build task
${pathSeparator}
- the character used by the operating system to separate components in file paths
1. gdb
1.1. 配置
1) launch
(1) 本地起程序
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
| { "version": "0.2.0", "configurations": [ { "name": "debug", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/run", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [ { "name": "LD_LIBRARY_PATH", "value": "/home/third-party/openssl/" }, ], "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb" } ] }
|
(2) 连接远程服务器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| { "name": "(gdb) Attach", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/runtime_output_directory/mysqld", "MIMode": "gdb", "miDebuggerServerAddress": "127.0.0.1:6666", "cwd": ".", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "Set Disassembly Flavor to Intel", "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true } ] }
|
1.2. 执行gdb命令
- 启动gdb后,在
Debug Console
执行-exec xxx
即可,-exec
后面跟gdb命令
六、配置 settings.json
1. 禁用git
1 2 3
| { "git.enabled": false }
|
七、基本使用的一些操作
1. 高级替换
- 使用
()
圈起来的正则在替换时按顺序变成$n
- 需要开启正则匹配
示例
- 查找
abc(.*)=(.*)def
- 替换
abc$2=$1def
效果将abc!@#=*()def
替换成abc*()=!@#def
小技巧和踩坑记
1. 在ubuntu上使用管理员打开vscode
1
| sudo code --user-data-dir="/path/to/.vscode-root" --no-sandbox --disable-gpu-sandbox
|