Skip to content

Commit

Permalink
kj key_bindings for vim mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Ariza committed Jul 9, 2020
1 parent 80bf05a commit 649350b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pgcli/key_bindings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import logging
from prompt_toolkit.enums import EditingMode
from prompt_toolkit.keys import Keys
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.key_binding.key_processor import KeyPress
from prompt_toolkit.filters import (
Condition,
ViInsertMode,
completion_is_selected,
is_searching,
has_completions,
Expand Down Expand Up @@ -124,4 +128,12 @@ def _(event):
"""Move down in history."""
event.current_buffer.history_forward(count=event.arg)

@kb.add("k", "j", filter=ViInsertMode())
def _(event):
"""
Typing 'kj' in Insert mode, should go back to navigation mode.
"""
_logger.debug('Detected kj keys.')
event.cli.key_processor.feed(KeyPress(Keys.Escape))

return kb

0 comments on commit 649350b

Please sign in to comment.