Reputation: 39
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.
Upvotes: 0
Views: 207
Reputation: 51974
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",
},
This is more robust than unbinding from the keyboard shortcuts UI because it doesn't require keeping a when-clause in sync with that of the default keybinding. I.e. If the default keybinding's when-clause changes, you won't have to update your unbinding.
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'"
},
Upvotes: 0
Reputation: 9883
Open the shortcut key setting page (Ctrl+K+S
) and enter "Escape"
for search.
The settings in the page to achieve the effect you want.
Upvotes: 0