When working with the interactive console in PyCharm (via IPython), is there any way to execute the currently loaded multiline statement from not the last line?
In Jupyter's QtConsole, this can be done by pressing Shift
+Enter
on any line of input. i.e.
In [1]: print("line 1")
... print("line 2")
Can be evaluated by pressing Shift
+Enter
regardless of where the caret is located. In the IPython-based interactive console in PyCharm, pressing Shift
+Enter
creates a new line below the current one and moves the caret to it, while Ctrl
+Enter
splits the line at the current caret position.
I could not find any settings that control this behavior; perhaps it is a limitation of IPython?
EDIT: In the regular IPython REPL, Alt
+Enter
accomplishes what I'm after, but this does not work in the PyCharm console, even after removing the default shortcut assigned to that keystroke ("Show Intention Actions")
Perhaps this link can help you:
https://www.jetbrains.com/help/pycharm/loading-code-from-editor-into-console.html
pressing Alt + Shift + E on a selection will execute the selected code in the console.
If there is no direct shortcut for this, at least you can do it with a workaround:
If you have selected some code, and you want to get to the bottom of the selection; or if you have just applied Alt+Shift+E and you realise that you have forgotten to edit something at PositonEND in order to use the trick above with Ctrl+Shift+Backspace, and you want to go back to PositionEND, you must simply copy / cut and paste the selected code, that will put your cursor to the end of the selection:
By the way, if you are in somewhat else than in the editor and you want to turn back, do not click inside the editor, but just click on the needed ".py"-tab then so that your latest selection information does not get lost.
If
you may use Ctrl+Alt+← (Left Arrow), though this is very often not helping you to get to that exact previous cursor place, being confusingly called: "Jump to Previous View Location". It does not always do what you would expect (I think).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With