skip to Main Content

I normally write code in a python script (.py-file) divided into cells (with # %%) and execute the cells or single lines of code in an interactive window to the right of the script.

The interactive window also has an interactive python shell at the bottom, which I use if I quickly want to write some code but not clutter my script. However, pressing Esc deletes the line. I can bring it back by pressing up arrow, but this only saves the last thing I typed, and I quite frequently press Esc accidentally due to using Vim at the same time.

Is it possible to disable Esc deleting the line? (Using Vim I can just press dd anyways…) I didn’t find anything in the settings.

2

Answers


  1. Put the following in keybindings.json (which you can open with the Preferences: Open Keyboard Shortcuts (JSON) command in the command palette):

    {
        "key": "escape",
        "command": "-interactive.input.clear",
    },
    

    The default keybinding at the time of this writing is:

    {
        "key": "escape",
        "command": "interactive.input.clear",
        "when": "!LinkedEditingInputVisible && !accessibilityHelpWidgetVisible && !breakpointWidgetVisible && !editorHasMultipleSelections && !editorHasSelection && !editorHoverVisible && !exceptionWidgetVisible && !findWidgetVisible && !inSnippetMode && !isComposing && !markersNavigationVisible && !notificationToastsVisible && !parameterHintsVisible && !renameInputVisible && !selectionAnchorSet && !suggestWidgetVisible && activeEditor == 'workbench.editor.interactive'"
    },
    
    Login or Signup to reply.
  2. Open the shortcut key setting page (Ctrl+K+S) and enter "Escape" for search.

    enter image description here

    The settings in the page to achieve the effect you want.

    enter image description here

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