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

Re: Readline-like ^W behavior

[Peter Stephenson]

>> Is it possible to make ^W delete the word to the left of the
>> cursor with the same word-boundary rules as in readline/bash?
>> Here's what I'm looking for:
>> [...]
> So you're assuming unix-word-rubout in bash?	(The usual
> bash/readline rules for words are to use alphanumerics only,
> but the default ^w binding does what you show.)

I'm a little confused here now:  bash(1) and readline(3) state
that ^W is by default bound to unix-word-rubout, which uses
whitespace for word boundaries:

  unix-word-rubout (C-w)
         Kill  the word behind point, using white space as a
         word boundary.  The killed text  is  saved  on  the

I tried making it explicity by putting

  "C-w": unix-word-rubout

in ~/.inputrc and (as expected) it made no difference.

> As you're using zsh 4.1.1, you have an easy solution: redefine
> backward-kill-word to the Swiss-army-knife function variant
> with `-match' appended, and set the style to use whitespace
> word boundaries:
>   bindkey '^w' backward-kill-word		# as before
>   autoload -U backward-kill-word-match
>   zle -N backward-kill-word backward-kill-word-match
>   zstyle ':zle:backward-kill-word' word-style whitespace

Thanks -- that's exactly what I was looking for! :-)


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