[vscode]在chrome中快速打开当前文件(2018-03

2018-03-05  本文已影响0人  ubo5

前言:

之前用过一个编辑器bracket,它有一个GUI插件直接在浏览器中打卡当前文件,很是不错。但是在文件管理和terminal的使用上觉得还是vscode更赞,所以利用了vscode的task把这个功能给移植过去。以下记录用于备忘。

过程

配置task文件

  1. ⌘+⇧+p 打开vs的控制台
  2. 搜索configure task命令
  3. 替换初始的task.json为以下文件
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks":[
        {
            "label": "browser",
            "osx": {
                "command": "/Applications/Google Chrome.app
                          /Contents/MacOS/Google Chrome"
            },
            "args": ["${file}"],
        }
    ]
}

说明:

给task配置快捷键

打开菜单栏的code>preferences>keyboard shortcuts(快捷键⌘K ⌘S)
打开advanced 配置文件keybindings.json,配置文件如下:

// Place your key bindings in this file to overwrite the defaults
[
    {
        "key": "ctrl+shift+b",
        "command": "workbench.action.tasks.runTask",
        "args": "browser"
    }
]

说明:

结果

这样在一个.htm[l]文件中,就可以用快捷键ctrl+shift+b来预览了。

上一篇 下一篇

猜你喜欢

热点阅读