Default bindings for token movement commands

There is no natural default binding for token movements. Add the
alt-{left,right,backspace,delete}, breaking some existing behavior.

For example, backward-delete-word is no longer bound to alt-backspace but
only to ctrl-backspace.  Unfortunately some terminals (particularly tmux)
don't support distinguishing ctrl-backspace from ctrl-h yet, so the loss
of alt-backspace may be tragic.

---

I guess we could also add:

    bind alt-B backward-token
    bind alt-F forward-token
    bind ctrl-W backward-kill-token
    bind alt-D kill-token

Those might be intercepted by the terminal on Linux, but I don't know where
that happens.

Tested on foot, kitty, alacritty, xterm, tmux, konsole and gnome-terminal.

Closes #10766
This commit is contained in:
Johannes Altmanninger
2024-10-05 21:44:29 +02:00
parent 2dafe81f97
commit 6af96a81a8
6 changed files with 28 additions and 6 deletions

View File

@@ -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 <cmds/fish_default_key
- :kbd:`ctrl-n`, :kbd:`ctrl-p` move the cursor up/down or through history, like the up and down arrow shared bindings.
- :kbd:`delete` or :kbd:`backspace` removes one character forwards or backwards respectively. This also goes for :kbd:`ctrl-h`, which is indistinguishable from backspace.
- :kbd:`delete` or :kbd:`backspace` or :kbd:`ctrl-h` removes one character forwards or backwards respectively.
- :kbd:`alt-backspace` removes one word backwards. If supported by the terminal, :kbd:`ctrl-backspace` does the same.
- :kbd:`ctrl-backspace` removes one word backwards and :kbd:`alt-backspace` removes one argument backwards.
- :kbd:`alt-<` moves to the beginning of the commandline, :kbd:`alt->` moves to the end.