pythonvisual-studio-codevssettings

VS Code keybindings: How to stop VSC from jumping to next line? (Shift + Enter)


I've been working with VS Code for quite awhile now and I was quite used to being able to execute selected parts of the python code (.py) with Shift + Enter keybinding. It worked both when i wanted to execute part of the code as well as when cursor was simply in the line that interested me.

However, very recently I've noticed that the same shortcut jumps to the next fragment of code, which I REALLY hate.

I'd appreciate any tips on how to disable jumping to the next line when executing lines.

enter image description here

I've figured that it might be related to the keybinding in settings, so I've deleted all of them but the highlighted one - still jumps to next line.

When I delete highlited line, it stops working altohether. I'm not use how to remove "jump to next line after execution" behaviour.

I've tried using custom macro

"macros": {
    "pythonRunCurrentLineAndStay": [
        "python.execSelectionInTerminal",
        "cursorUp",
        "cursorUp",
        "cursorUp",
    ]
}

but the jump to next part of the code happens after execution of macro, so the end effect is the same.

Edit: The debug console shows something like this:

2023-11-22 20:55:12.846 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-11-22 20:55:12.846 [info] [KeybindingService]: \ Keyboard event cannot be dispatched
2023-11-22 20:55:12.847 [info] [KeybindingService]: / Received  keydown event - modifiers: [shift], code: ShiftLeft, keyCode: 16, key: Shift
2023-11-22 20:55:12.847 [info] [KeybindingService]: | Converted keydown event - modifiers: [shift], code: ShiftLeft, keyCode: 4 ('Shift')
2023-11-22 20:55:12.847 [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
2023-11-22 20:55:12.998 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-11-22 20:55:12.998 [info] [KeybindingService]: | Resolving shift+Enter
2023-11-22 20:55:12.998 [info] [KeybindingService]: \ From 16 keybinding entries, matched python.execSelectionInTerminal, when: editorTextFocus && !findInputFocussed && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python', source: user extension ms-python.python.
2023-11-22 20:55:12.998 [info] [KeybindingService]: / Received  keydown event - modifiers: [shift], code: Enter, keyCode: 13, key: Enter
2023-11-22 20:55:12.998 [info] [KeybindingService]: | Converted keydown event - modifiers: [shift], code: Enter, keyCode: 3 ('Enter')
2023-11-22 20:55:12.998 [info] [KeybindingService]: | Resolving shift+Enter
2023-11-22 20:55:12.999 [info] [KeybindingService]: \ From 16 keybinding entries, matched python.execSelectionInTerminal, when: editorTextFocus && !findInputFocussed && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python', source: user extension ms-python.python.
2023-11-22 20:55:12.999 [info] [KeybindingService]: + Invoking command python.execSelectionInTerminal.
2023-11-22 20:55:13.133 [info] [KeybindingService]: + Ignoring single modifier shift due to it being pressed together with other keys.

Solution

  • If you are using the latest version of Python extension(2023.20.0). Try to downgrade to 2023.18.0.

    enter image description here