diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 66c83f143..c8dea3f29 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -31,6 +31,8 @@ Notable backwards-incompatible changes See :ref:`below ` for details. - Fish no longer supports terminals that fail to ignore OSC or CSI sequences they don't recognize. The typical problem is that terminals echo the raw sequences sent by fish instead of silently ignoring them. +- :kbd:`alt-left` and :kbd:`alt-right` will now move by one argument (which may contain quoted spaces), not just one word. +- :kbd:`alt-backspace` will delete an entire argument, not just one word. - ``random`` now uses a different random number generator and so the values you get even with the same seed have changed. Notably, it will now work much more sensibly with very small seeds. The seed was never guaranteed to give the same result across systems, @@ -162,6 +164,7 @@ New or improved bindings - During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager. Same for autosuggestions. - :kbd:`ctrl-Z` (also known as :kbd:`ctrl-shift-z`) is now bound to redo. +- :kbd:`alt-delete` now deletes the argument (which may contain quoted spaces) right of the cursor. - Some improvements to the :kbd:`alt-e` binding which edits the commandline in an external editor: - The editor's cursor position is copied back to fish. This is currently supported for Vim and Kakoune. - Cursor position synchronization is only supported for a set of known editors. This has been extended by also resolving aliases. For example use ``complete --wraps my-vim vim`` to synchronize cursors when ``EDITOR=my-vim``. diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index 60a43f11d..654e2b16c 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -303,7 +303,7 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit - :kbd:`alt-enter` inserts a newline at the cursor position. This is useful to add a line to a commandline that's already complete. -- :kbd:`alt-left` (``←``) and :kbd:`alt-right` (``→``) move the cursor one word left or right (to the next space or punctuation mark), or moves forward/backward in the directory history if the command line is empty. If the cursor is already at the end of the line, and an autosuggestion is available, :kbd:`alt-right` (``→``) (or :kbd:`alt-f`) accepts the first word in the suggestion. +- :kbd:`alt-left` (``←``) and :kbd:`alt-right` (``→``) move the cursor one argument left or right, or moves forward/backward in the directory history if the command line is empty. If the cursor is already at the end of the line, and an autosuggestion is available, :kbd:`alt-right` (``→``) (or :kbd:`alt-f`) accepts the first argument in the suggestion. - :kbd:`ctrl-left` (``←``) and :kbd:`ctrl-right` (``→``) move the cursor one word left or right. These accept one word of the autosuggestion - the part they'd move over. @@ -327,6 +327,8 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit - :kbd:`alt-d` or :kbd:`ctrl-delete` moves the next word to the :ref:`killring`. +- :kbd:`alt-delete` moves the next argument to the :ref:`killring`. + - :kbd:`alt-h` (or :kbd:`f1`) shows the manual page for the current command, if one exists. - :kbd:`alt-l` lists the contents of the current directory, unless the cursor is over a directory argument, in which case the contents of that directory will be listed. @@ -360,9 +362,9 @@ To enable emacs mode, use :doc:`fish_default_key_bindings ` moves to the end. diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index 631a80b41..13faef8ca 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -54,8 +54,8 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod $legacy_bind --preset $argv -k sright forward-bigword $legacy_bind --preset $argv -k sleft backward-bigword - bind --preset $argv alt-right nextd-or-forward-word - bind --preset $argv alt-left prevd-or-backward-word + bind --preset $argv alt-right nextd-or-forward-token + bind --preset $argv alt-left prevd-or-backward-token bind --preset $argv alt-up history-token-search-backward bind --preset $argv alt-down history-token-search-forward diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index 816c0071f..3eb8f7afb 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -74,8 +74,9 @@ function fish_default_key_bindings -d "emacs-like key binds" bind --preset $argv alt-u upcase-word bind --preset $argv alt-c capitalize-word - bind --preset $argv alt-backspace backward-kill-word + bind --preset $argv alt-backspace backward-kill-token bind --preset $argv ctrl-backspace backward-kill-word + bind --preset $argv alt-delete kill-token bind --preset $argv ctrl-delete kill-word bind --preset $argv alt-b backward-word bind --preset $argv alt-f forward-word diff --git a/share/functions/nextd-or-forward-token.fish b/share/functions/nextd-or-forward-token.fish new file mode 100644 index 000000000..420911fa1 --- /dev/null +++ b/share/functions/nextd-or-forward-token.fish @@ -0,0 +1,8 @@ +function nextd-or-forward-token --description "If commandline is empty, run nextd; else move one argument to the right" + if test "$(commandline; printf .)" = \n. + nextd + commandline -f repaint + return + end + commandline -f forward-token +end diff --git a/share/functions/prevd-or-backward-token.fish b/share/functions/prevd-or-backward-token.fish new file mode 100644 index 000000000..263e8af51 --- /dev/null +++ b/share/functions/prevd-or-backward-token.fish @@ -0,0 +1,8 @@ +function prevd-or-backward-token --description "If commandline is empty, run prevd; else move one argument to the left" + if test "$(commandline; printf .)" = \n. + prevd + commandline -f repaint + return + end + commandline -f backward-token +end