Creating a Python .gitignore from a template via a keyboard shortcut
Save the template to a central location e.g. C:\Users\nyep\<username>\templates.
Create a new task in tasks.json in VS Code, replacing <file path> with the actual path to your templates folder:
1
2
3
4
5
6
7
8
9
10
11
...
{
"label": "Add .gitignore from template",
"type": "shell",
"command": "Copy-Item -Path '<file path>>\\.gitignore' -Destination '${workspaceFolder}\\.gitignore'",
"presentation": {
"reveal": "silent",
"panel": "shared"
}
}
...
Add a key binding in keybindings.json:
1
2
3
4
5
6
7
...
{
"key": "ctrl+f1",
"command": "workbench.action.tasks.runTask",
"args": "Add .gitignore from template"
}
...
This post is licensed under CC BY 4.0 by the author.