mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Merge pull request #1239 from xonsh/vi_mode_change
enable character selection in vi_mode
This commit is contained in:
commit
3d239b134a
3 changed files with 22 additions and 2 deletions
14
news/vi_mode_change.rst
Normal file
14
news/vi_mode_change.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
**Added:** None
|
||||
|
||||
**Changed:**
|
||||
|
||||
* In ``VI_MODE``, the ``v`` key will enter character selection mode, not open
|
||||
the editor. ``Ctrl-X Ctrl-E`` will still open an editor in any mode
|
||||
|
||||
**Deprecated:** None
|
||||
|
||||
**Removed:** None
|
||||
|
||||
**Fixed:** None
|
||||
|
||||
**Security:** None
|
|
@ -3,7 +3,8 @@
|
|||
import builtins
|
||||
|
||||
from prompt_toolkit.enums import DEFAULT_BUFFER
|
||||
from prompt_toolkit.filters import Condition, Filter, IsMultiline
|
||||
from prompt_toolkit.filters import (Condition, Filter, IsMultiline,
|
||||
HasSelection)
|
||||
from prompt_toolkit.keys import Keys
|
||||
from xonsh.aliases import exit
|
||||
from xonsh.tools import ON_WINDOWS
|
||||
|
@ -125,6 +126,7 @@ def load_xonsh_bindings(key_bindings_manager):
|
|||
Load custom key bindings.
|
||||
"""
|
||||
handle = key_bindings_manager.registry.add_binding
|
||||
has_selection = HasSelection()
|
||||
|
||||
@handle(Keys.Tab, filter=TabShouldInsertIndentFilter())
|
||||
def _(event):
|
||||
|
@ -134,6 +136,11 @@ def load_xonsh_bindings(key_bindings_manager):
|
|||
"""
|
||||
event.cli.current_buffer.insert_text(env.get('INDENT'))
|
||||
|
||||
@handle(Keys.ControlX, Keys.ControlE, filter=~has_selection)
|
||||
def open_editor(event):
|
||||
""" Open current buffer in editor """
|
||||
event.current_buffer.open_in_editor(event.cli)
|
||||
|
||||
@handle(Keys.BackTab)
|
||||
def insert_literal_tab(event):
|
||||
""" Insert literal tab on Shift+Tab instead of autocompleting """
|
||||
|
|
|
@ -36,7 +36,6 @@ class PromptToolkitShell(BaseShell):
|
|||
'enable_auto_suggest_bindings': True,
|
||||
'enable_search': True,
|
||||
'enable_abort_and_exit_bindings': True,
|
||||
'enable_open_in_editor': True,
|
||||
}
|
||||
|
||||
self.key_bindings_manager = KeyBindingManager(**key_bindings_manager_args)
|
||||
|
|
Loading…
Add table
Reference in a new issue