Search code examples
visual-studioideintellij-ideakey-bindings

Give Intellij IDEA Visual Studio's F5, F10 and F11-key functionality


In Visual Studio, F5 is used both to start debugging and to resume program execution once debugging has started (or "continue"). Intellij has separate commands for debugging (Shift+F9) and resume program F9).

Pressing F9 (resume program) when the debugger is not running brings up a context menu with a list of launch configurations, while pressing Shift+F9 (start debugging) when the debugger is running appears to start a new instance of the program and kill the old instance (!). I can map F5 to both resume program and start debugging, but it behaves as if it was mapped to resume program alone. Instead, I'd like F5 to resume program if the debugger is running, and start debugging otherwise.

Is there any way to change the functionality of a key in Intellij based on whether the debugger is already running, so that I can make the F5 behave like in Visual Studio?

On a related note, is there some way to make F10 and F11 (Step Over/Step Into) start debugging at the first line if the debugger is not already running, also like in Visual Studio?


Solution

  • ... while pressing Shift+F9 (start debugging) when the debugger is running appears to start a new instance of the program and kill the old instance (!)

    By default, typing Shift+F9 while a debug session is running will start a new instance in a new tab within the debug tool window. The old instance is still running in a separate tab. If you have the "Single Instance Only" option selected in the Run/Debug configuration, IDEA will prompt you if you wish to stop the current instance. However, if at some point you selected the "Do not show this dialog in the future" option, then it will default to stopping and rerunning.

    Is there any way to change the functionality of a key in Intellij based on whether the debugger is already running, so that I can make the F5 behave like in Visual Studio?

    Not directly. However, see next answer...

    On a related note, is there some way to make F10 and F11 (Step Over/Step Into) start debugging at the first line if the debugger is not already running, also like in Visual Studio?

    If say you map F5 to both "Debug (start)" and "Step Over" (or one of the other step actions) it will start the debugger when not running and perform the step action when not running. I'm not sure why this will not work for doubling up the start debug and resume actions; it most likely has to do with how the editor handles certain actions.

    You may want to consider opening a feature request for your desired behavior: http://youtrack.jetbrains.com