Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: emulate bash key bindings



On Tue, 2020-01-07 at 21:38 +0300, Andrey Butirsky wrote:
> Hello,
> 
> after 25 years of bash, I'm doing my first steps with Zsh.
> 
> I'm trying to reproduce main bash key bindings in Zsh, so I started with:
> 
> autoload -U select-word-style
> select-word-style bash
> 
> But sill, I need to have different word boundaries for some bindings, 
> e.g Ctrl+W should kill space-delimeted word.
> 
> What is the best way to achieve that? Can I avoid creating custom widgets?

The most configurable way is to use the special widget, the same one
that you've now got bind to the usual backward-kill-word functions, but
under a different name.  Then you can set a special style for the
behaviour.  Then you have all the same possibilities as the widget
functions at your fingertips, without having to redefine any functions.


# Create widget backward-kill-space-word, using the generic
# backward-kill-word widget function.
zle -N backward-kill-space-word backward-kill-word-match
# Tell it to use "space" style for words.
zstyle ':zle:backward-kill-space-word:*' word-style space
# Bind it.
bindkey '^W' backward-kill-space-word


The zshcontrib manual lists the various styles.

pws



Messages sorted by: Reverse Date, Date, Thread, Author