Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get backward-delete-word to add to the current kill-ring in zsh?

Tags:

zsh

I use zsh and I would like backward-kill-word in Emacs mode to behave like Emacs (and bash, fwiw). The behaviour that I have failed to reproduce is that when I press multiple backward-kill-word Emacs adds the killed text to the cut buffer (the first item in the killring) making it possible for me to yank everything with one yank command.

How can I configure zsh to behave like this aspect of Emacs editors?

like image 325
Olof Avatar asked Oct 31 '25 08:10

Olof


1 Answers

Actually, by default, Zsh's cut buffer works exactly the same as in Emacs. Just use zsh -f to start Zsh without config files and try it.

However, are you perhaps using zsh-autosuggestions or zsh-syntax-highlighting? There are bugs in these plugins that break this feature:

  • https://github.com/zsh-users/zsh-autosuggestions/issues/363
  • https://github.com/zsh-users/zsh-syntax-highlighting/issues/150#issuecomment-658381485

Fixes have been submitted, but for zsh-autosuggestions, none have yet been merged, and for zsh-syntax-highlighting, the fix won't work until Zsh 5.9 has been released.

In the meantime, though, zsh-autocomplete contains a workaround that fixes the problem. If you add that plugin, your cut buffer will start functioning like normal again.

like image 170
Marlon Richert Avatar answered Nov 02 '25 22:11

Marlon Richert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!