skip to Main Content

On VSCode, when using #%% cells, shift-enter no longer executes a cell in the interactive window and moves to the next cell. It used to work for many years, but now shift-enter on some line of code throws an error in a new window titled ‘Python REPL’. I can still use control-enter to execute a cell in the interactive window, but that does not move the cursor to the next cell. Could a VSCode update have changed the short-cut functionality?

2

Answers


  1. I tried using shift-enter in the new version of vscode, which executes cells in an interactive window. You can try updating your vscode version, or open the shortcut settings by typing the command Preferences: Open Keyboard Shortcuts in the command palette. You can check if the Shift-Enter shortcut settings have changed, or create a new shortcut for executing cells in the interactive window. You can learn more about the shortcut settings in the document.

    Login or Signup to reply.
  2. Step 1:
    Open Settings (Ctrl + .) and search for python.repl. Then disable:

    • python.REPL: Send to Native REPL

    Step 2: Open keybindings.json by pressing Ctrl + Shift + P > Search for keyboard > Select Preferences: Open Keyboard Shortcuts (JSON). Add or change shift + enter if already present:

      {
        "key": "shift+enter",
        "command": "-jupyter.runcurrentcelladvance",
        "when": "notebookCellListFocused && !interactiveEditorFocused && notebookCellType == 'code' || editorTextFocus && inputFocus && notebookEditorFocused && !interactiveEditorFocused"
      },
    

    This when condition is copied from python.execInRepl command’s keyboard shortcut which is taking over Shift + Enter

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search