From 8ddd512fbab248029a700921e0496b098c8ec93c Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 19 Mar 2020 18:18:11 +0100 Subject: [PATCH] Refine when we expand abbreviations - ctrl-space will insert a space without expanding abbrs - ")" or alt-enter will expand abbrs Fixes #6658 --- doc_src/index.rst | 2 ++ share/functions/__fish_shared_key_bindings.fish | 4 ++-- share/functions/fish_default_key_bindings.fish | 4 ++++ share/functions/fish_vi_key_bindings.fish | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc_src/index.rst b/doc_src/index.rst index 67b87cf0f..0ddb9e7f3 100644 --- a/doc_src/index.rst +++ b/doc_src/index.rst @@ -1329,6 +1329,8 @@ Some bindings are shared between emacs- and vi-mode because they aren't text edi - :kbd:`Alt`\ +\ :kbd:`S` Prepends `sudo` to the current commandline. +- :kbd:`Control`\ +\ :kbd:`Space` Inserts a space without expanding an :ref:`abbreviation `. (for vi-mode this only applies to insert-mode) + .. _emacs-mode: Emacs mode commands diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index aaf2342b9..f39b3d0b3 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -39,8 +39,8 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod # shift-tab does a tab complete followed by a search. bind --preset $argv --key btab complete-and-search - bind --preset $argv \e\n "commandline -i \n" - bind --preset $argv \e\r "commandline -i \n" + bind --preset $argv \e\n "commandline -f expand-abbr; commandline -i \n" + bind --preset $argv \e\r "commandline -f expand-abbr; commandline -i \n" bind --preset $argv -k down down-or-search bind --preset $argv -k up up-or-search diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index 47ffc6f9b..40c0b1754 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -33,6 +33,10 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis # Space expands abbrs _and_ inserts itself. bind --preset $argv " " self-insert expand-abbr + bind --preset $argv ")" self-insert expand-abbr + # Ctrl-space inserts space without expanding abbrs + bind -k nul 'commandline -i " "' + bind --preset $argv \n execute bind --preset $argv \r execute diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 6893f48ba..ddfaf6e86 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -56,6 +56,9 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' bind -s --preset -M insert "" self-insert # Space expands abbrs _and_ inserts itself. bind -s --preset -M insert " " self-insert expand-abbr + bind --preset $argv ")" self-insert expand-abbr + # Ctrl-space inserts space without expanding abbrs + bind -k nul 'commandline -i " "' # Add a way to switch from insert to normal (command) mode. # Note if we are paging, we want to stay in insert mode