[Python] Prevent VSCode from skipping to next non empty line when executing current line with...

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using VSCode extensively in my workflow together with the Vim extension. I frequently execute single lines in the editor in Python interactive mode. On Shift+Enter (with no characters highlighted) it is supposed to only execute the current line and not change the cursor position.

    This behaviour changes sometimes and VSCode skips to the next non empty line in the editor after hitting Shift+Enter which hinders my desired workflow considerably.

    This behaviour started showing up before, and a full reinstall fixed it. But now I did a full reinstall and Code still jumps the cursor to the next line on Shift+Enter.

    Is there a way to prevent this and get the old behaviour persistently again?

    My Keybindings and settings file look like this:

    // Place your key bindings in this file to override the defaultsauto[]
    [
    {
    "key": "shift+down",
    "command": "workbench.action.terminal.toggleTerminal",
    "when": "terminal.active"
    },
    {
    "key": "shift+up",
    "command": "workbench.action.focusActiveEditorGroup"
    }
    ]


    {
    "workbench.colorTheme": "Default Dark Modern",
    "git.openRepositoryInParentFolders": "never",
    }


    I tried completly reinstalling (uninstall vscode, remove all local folders in appdata). This fixed the problem before. On encountering the problem again, I was not able to revert to the desired cursor behaviour with this approach.

    The only keyboard shortcut active in editor with shift+enter is Python Run Selection/Line in Python terminal. To use this command the Python extension has to be activated, all others are deactivated.

    Current keyboard shortucuts with shift+Enter

    EDIT:

    I found the solution with the help of the comments below:

    The python extension version I was using was: 2023.20.0 which released about a two weeks ago.

    Downgrading to 2023.18.0 fixed the problem. Apparently they added this feature per default but it would be nice to know how to deactivate without having to downgrade.

    Continue reading...

Compartilhe esta Página