Home > Back-end >  Limit F5 (Run->Start Debugging) to language modes VS Code can execute
Limit F5 (Run->Start Debugging) to language modes VS Code can execute

Time:10-22

I sometimes mistakenly press F5 in a VS Code tab containing SQL code (mostly when my eyes are on the other screen looking at pgAdmin and not realizing that the focus is on the VS Code window). VS Code then launches a Python interpreter on my SQL code, failing of course.

I want to avoid this. Essentially I want F5 to be limited to editor tabs containing Python or other program code that VS Code is able to execute. How can I achieve this?

CodePudding user response:

Add a keybinding at the end of the keybindings.json file. It will set the action to do nothing on F5 for a selection of languages

{
  "key": "F5",
  "command": "type",
  "args": { "text": "" },
  "when": "editorLangId == sql || editorLangId == plaintext"
}
  • Related