VSCode - how to keybind an external command

流过昼夜 提交于 2019-12-05 05:01:49

问题


Im trying to run "puppet-lint -f (currently open file)

The Puppet extenstion provides puppet-lint check, but doesnt auto fix any issues, it just gives warnings. How can I add a keyboard shortcut to run "puppet-lint -f" on a file Im currently editing?

Thanks


回答1:


I don't know anything about the Puppet extension but in general here is how you can bind a shell command to a keychord:

Make a task for it (.vscode/tasks.json):

{
    "version": "2.0.0",
    {
         "label": "node version",
         "command": "node",
         "args": [
             "-v"
         ],
         "type": "shell"
    }
}

In the args: you may use ${file} for the current file.

Then in keybindings.json:

{
    "key": "shift+escape",
    "command": "workbench.action.tasks.runTask",
    "args": "node version"
  },



回答2:


co-author of the extension here. You can have the Puppet VSCode Extension run puppet-lint fix on the current file by using the Format Document command. You can then configure VSCode to run format on save.



来源:https://stackoverflow.com/questions/50725243/vscode-how-to-keybind-an-external-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!