From 8a09c99f36977ec98ebbc7c1e5255402da5dbaa8 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Tue, 31 Jan 2017 10:58:06 -0800 Subject: [PATCH] Escape in vi mode to end paging, but stay in insert mode Change the escape key binding in insert mode (in vi key bindings) to check if we are in paging mode. If so, emit cancel and stay in insert mode. Otherwise perform the current behavior of switching back to default mode and adjusting the cursor. Fixes #2871 --- share/functions/fish_vi_key_bindings.fish | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 51d8adebf..5acd13d44 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -64,7 +64,9 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' # Add way to kill current command line while in insert mode. bind -M insert \cc __fish_cancel_commandline # Add a way to switch from insert to normal (command) mode. - bind -M insert -m default \e backward-char force-repaint + # Note if we are paging, we want to stay in insert mode + # See #2871 + bind -M insert \e "if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char force-repaint; end" # Default (command) mode bind :q exit