简体   繁体   中英

How to make fish shell delete words like bash does

I'm giving a second try to the fish shell. One thing that really annoys me is the "new" behaviour of Ctrl + w shortcut.

Consider following situation:

$ 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?

"\\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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM