From 3af8dd0efee2abbf2f3c1856d5cf8115a952708f 2017-02-23 18:02:07 From: Matthias Bussonnier Date: 2017-02-23 18:02:07 Subject: [PATCH] Backport PR #10330: Add config option for vi/emacs style open-editor shortcuts F2 is always enabled, but passing the option to prompt_toolkit binds `v` (in vi mode, overriding its 'visual mode' function), and `C-X C-E` in emacs mode. Closes gh-10259 Closes gh-10278 --- diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py index d1b414e..f551fd4 100644 --- a/IPython/terminal/interactiveshell.py +++ b/IPython/terminal/interactiveshell.py @@ -192,7 +192,12 @@ class TerminalInteractiveShell(InteractiveShell): default_value='multicolumn').tag(config=True) highlight_matching_brackets = Bool(True, - help="Highlight matching brackets .", + help="Highlight matching brackets.", + ).tag(config=True) + + extra_open_editor_shortcuts = Bool(False, + help="Enable vi (v) or Emacs (C-X C-E) shortcuts to open an external editor. " + "This is in addition to the F2 binding, which is always enabled." ).tag(config=True) @observe('term_title') @@ -221,7 +226,9 @@ class TerminalInteractiveShell(InteractiveShell): return # Set up keyboard shortcuts - kbmanager = KeyBindingManager.for_prompt() + kbmanager = KeyBindingManager.for_prompt( + enable_open_in_editor=self.extra_open_editor_shortcuts, + ) register_ipython_shortcuts(kbmanager.registry, self) # Pre-populate history from IPython's history database