chiachan
chiachan
Published on 2025-03-23 / 12 Visits
0

vscode使用笔记

vscode使用笔记

之前习惯用JetBrains系列了。快捷键和vscode使用很多不适用。但是随着AI编译器的普及,如cursor、trea,winsurf等,基本都是基于vscode起来的。
为了后续开发能更得心应手,开始转vscode进行开发。
下面记录vscode使用笔记,尽量把常用、有用、高效的记录下来。

快捷建

快捷键 功能 附件说明
Cmd+P 文件搜索
Cmd+Shift+P 命令面板
Cmd+Shift+X 扩展:商店
Cmd+Shift+D 调试面板
Cmd+Shift+Option+鼠标左键 多行编辑
Cmd+Shift+K 删除当前行
Shift+Option+↑ 在上一行拷贝当前行
Shift+Option+↓ 在下一行拷贝当前行
Option+↑/↓ 移动当前行
Option+←/→ 光标移动到单词首尾
Cmd+↑/↓ 光标移动到文件首尾
Cmd+↑/↓ 光标移动到行首尾
Ctrl + - 光标回到上一步
Ctrl + G 跳转到指定行
Cmd+ Shift + O 调出当前文件的符号,用于索引函数
cmd + F12 跳转到函数的实现位置
F12 跳转到函数的定义处 同 Cmd+ 鼠标左键
Cmd + [ 减少缩进
Cmd + ] 增加缩进
Cmd + \ 编辑器分屏
F8 跳转到下一个报错点
Shift + F8 跳转到上一个报错点
Cmd + Shift + M 打开问题面板
Cmd+Shift+F 全局搜索
Cmd+Shift+H 全局搜索替换
Cmd+F 搜索
Cmd+Option+H 替换
F9 断点/取消断点 调试
F5 开始/继续 调试
F11 进入 调试
Shift+F11 跳出 调试
F10 跳过 调试

命令面板

快捷键 功能 附件说明
Preferences: Open User Settings (JSON) 打开settings.json文件
Configure Display Language 切换语言

launch.json文件配置go程序

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "server", // 调试名称
            "type": "go", // 程序类型
            "request": "launch", // 调试请求类型 launch启动调试 attach附加调试
            "mode": "debug", // 调试模式, remote表示远程调试 debug本地dlv模型 
            "program": "${workspaceFolder}/server/main.go", // 调试程序
            "cwd": "${workspaceFolder}/server", // 工作目录
            "env": { // 环境变量
                "GIN_MODE": "debug" 
            },
            "args": ["-c","config.yaml"] // 附加参数
        },{
            "name": "remote",
            "type": "go",
            "request": "attach",
            "mode": "remote",
            "program": "${fileDirname}",
            "host": "192.168.88.210", // 远程连接地址
            "port": 2345, // 远程连接调试端口
            "remotePath": "/home/ubuntu/go/src/EngService/server" // 远程项目代码路径,必须是绝对路径且路径为main包所在
        }
    ]
}

插件篇

中文插件

搜索Chinese 找到截图上第一个,安装后

image-eitx.png

安装完成后,右下角弹出这个。点击

image-kqkb.png

后续手动切换

  1. 按下“Ctrl+Shift+P/Cmd+Shift+P"组合键以显示“命令面板”
  2. 键入“display”以筛选并显示“Configure Display Language”命令。按“Enter”
  3. 选择语言确定即可。

image-esmp.png

image-rwhu.png

Github Colipot

  • 使用github-copilot-proxies插件 安装服务,建议docker compose模式
    • 白嫖党上硅基流动注册个好,创建个api-key。然后使用免费模型
    • 白嫖党的docker-compose.yaml需要修改下面几个
      - CODEX_API_BASE=https://api.siliconflow.cn/v1/completions # 代码补全API地址
        - CODEX_API_KEY=<上面创建的api-key># 代码补全API密钥, 支持多个轮询APIKEY,用英文逗号分隔
        - CODEX_API_MODEL_NAME=Qwen/Qwen2.5-Coder-7B-Instruct # 代码补全API模型名称
        # 聊天对话配置
        - CHAT_API_BASE=https://api.siliconflow.cn/v1/chat/completions # 聊天补全API地址
        - CHAT_API_KEY=<上面创建的api-key> # 聊天补全API密钥
        - CHAT_API_MODEL_NAME=Qwen/Qwen2.5-Coder-7B-Instruct # 聊天补全API模型名称
      
  • 修改/etc/hosts文件添加一下行
127.0.0.1 copilot.supercopilot.top
127.0.0.1 api.copilot.supercopilot.top
127.0.0.1 copilot-proxy.copilot.supercopilot.top
127.0.0.1 copilot-telemetry-service.copilot.supercopilot.top
  • vscode的setting.json文件配置成参考
{
   "http.proxyAuthorization": null,
   "http.proxy": "http://127.0.0.1:6152",
   "https.proxy": "http://127.0.0.1:6152",
   "http.noProxy": [
       "localhost",
       "127.0.0.*",
       "copilot.supercopilot.top",
       "api.copilot.supercopilot.top",
       "copilot-proxy.copilot.supercopilot.top",
       "copilot-telemetry-service.copilot.supercopilot.top"
   ],
   "github.copilot.advanced": {
       "authProvider": "github-enterprise",
       "debug.overrideCAPIUrl": "https://api.copilot.supercopilot.top",
       "debug.overrideProxyUrl": "https://copilot-proxy.copilot.supercopilot.top",
       "debug.chatOverrideProxyUrl": "https://api.copilot.supercopilot.top/chat/completions",
       "debug.overrideFastRewriteEngine": "v1/engines/copilot-centralus-h100",
       "debug.overrideFastRewriteUrl": "https://api.copilot.supercopilot.top"
       },
   "github-enterprise.uri": "https://copilot.supercopilot.top"
}

go代码不能正确跳转

我也没试过,先记录下,等遇到了再试试

"go.toolsEnvVars": {
        "GOFLAGS": "-mod=vendor" // "GOFLAGS": "-mod=mod"
    }

参考文献