Vscode使用笔记

特殊快捷键

转到括号 Ctrl + Shift + \

转到下个更改 Alt + F3

删除空行(正则)

^\s*(?=\r?$)\n

创建生成任务

配置生成任务

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build", // 取个名字
      "type": "shell",
      "command": "g++ -g hello.cpp -o hello", // 执行的命令
      "group": {
        // 从这里
        "kind": "build",
        "isDefault": true
      }, // 到这里,设置为默认构建任务,按Ctrl+Shift+B立即执行,不必选择
      "problemMatcher": "$gcc"// 问题匹配程序
    }
  ]
}
绑定快捷键

在keybindding.json中修改:

{
  "key": "ctrl+h",
  "command": "workbench.action.tasks.runTask",
  "args": "Run tests"
}
{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Run tests",
      "type": "shell",
      "command": "./scripts/test.sh",
      "windows": {
        "command": ".\\scripts\\test.cmd"
      },
      "group": "test",
      "presentation": {
        "reveal": "always",
        "panel": "new"
      }
    }
  ]
}
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "task",
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "command": "cd C:/Users/gaochaowei/Documents/code.work/012_go/007_RoyalCloud;go run ./main.go",
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": true,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            }
        },
    ]
}

 

在JSON中设置快捷键

位置

C:\Users\xxxxx\AppData\Roaming\Code\User\keybindings.json

示例

{
        "key": "Ctrl+U",
        "command":"workbench.action.tasks.runTask",
        "args": "scp"
}

输出行为

有时您想要控制“集成终端”面板在运行任务时的行为。例如,您可能希望最大化编辑器空间,并且仅在认为存在问题时才查看任务输出。可以使用presentation任务的属性来控制终端的行为。它提供以下属性:

  • 显示:控制是否将集成终端面板置于前面。有效值为:
    • 始终 -面板总是放在最前面。这是默认值。
    • 从不 -用户必须使用“ 视图” >“ 终端”命令(Ctrl +`)将终端面板显式显示在最前面 。
    • 无声 -仅在不扫描输出中是否有错误和警告的情况下,才将终端面板置于前面。
  • focus:控制终端是否获取输入焦点。默认值为false。
  • echo:控制是否在终端中回显执行的命令。默认值为true。
  • showReuseMessage:控制是否显示“终端将被任务重用,按任意键将其关闭”消息。
  • panel:控制是否在任务运行之间共享终端实例。可能的值为:
    • shared共享终端,并将其他任务运行的输出添加到同一终端。
    • 专用:终端专用于特定任务。如果再次执行该任务,则终端将被重用。但是,不同任务的输出显示在不同终端中。
    • new:该任务的每次执行都使用新的干净终端。
  • clear:控制在运行此任务之前是否清除终端。默认值为false。
  • group:控制是否使用拆分窗格在特定的终端组中执行任务。同一组中的任务(由字符串值指定)将使用拆分终端而不是新的终端面板显示。

 修正中文显示乱码

文件->首选项->设置 ->搜索
“files.autoGuessEncoding”: false
将其用户设置改为
“files.autoGuessEncoding”: true

posted @ 2020-09-18 11:14  James_gao  阅读(333)  评论(0编辑  收藏  举报