Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode - how to keybind an external command

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

like image 428
perfecto25 Avatar asked Jul 04 '26 02:07

perfecto25


2 Answers

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",
    "tasks": [{
         "label": "node version",
         "command": "node",
         "args": [
             "-v"
         ],
         "type": "shell"
    }]
}

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

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"
  },
like image 161
Mark Avatar answered Jul 07 '26 14:07

Mark


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.

like image 36
James Pogran Avatar answered Jul 07 '26 14:07

James Pogran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!