Issue
I'm giving a second try to the fish shell. One thing that really annoys me is the "new" behaviour of Ctrl+w shortcut.
$ vim ~/.config/fish/config.fish
...having the cursor at the end of the line.
When you press Ctrl+w, following happens:
- in bash:
~/.config/fish/config.fish
is deleted - in fish: only
config.fish
is deleted
How can I make fish delete words that are separated by spaces only?
Solution
"\cw" (in fish's notation) is bound to "backward-kill-path-component" (which bind \cw
will tell you).
If you wish, you can bind it to something else, including input functions like "backward-kill-word" or any fish script - bind \cw backward-kill-word
or bind \cw "commandline -rt ''"
(which will remove the entire current token) or bind \cw backward-kill-bigword
. See the bind documentation or bind --help
for more information.
The difference between "word" and "bigword" here is that "word" will only go to the next non-word-character, which can be a "." or "/" or "-", among others, while "bigword" will truly go to the next whitespace character.
Note that the "bigword" functions have only been introduced in fish 2.3.0.
You can try these incantations in an interactive shell. If you decide to make it permanent, you'll need to add them to a function called fish_user_key_bindings
.
Answered By - faho Answer Checked By - Katrina (WPSolving Volunteer)