VSCode-如何键盘绑定外部命令 [英] VSCode - how to keybind an external command

查看:172
本文介绍了VSCode-如何键盘绑定外部命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行"puppet-lint -f(当前打开的文件)

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

Puppet扩展程序提供puppet-lint检查,但不会自动修复任何问题,它只会发出警告.如何添加键盘快捷方式以在我当前正在编辑的文件上运行"puppet-lint -f"?

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?

谢谢

推荐答案

我对Puppet扩展一无所知,但总的来说,这是如何将Shell命令绑定到键盘弦上的方法:

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

为其执行任务(.vscode/tasks.json):

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

args中,您可以将${file}用于当前文件.

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

然后将此选项添加到keybindings.json(您可以在命令面板"的首选项:打开键盘快捷键(JSON)"下找到它们):

Then add this option to your keybindings.json (you can find them in Command Palette under "Preferences: Open keyboard shortcuts (JSON)"):

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

这篇关于VSCode-如何键盘绑定外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆