Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Fwd: Strange behaviour in zsh's emacs bindings
- X-seq: zsh-users 13724
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Fwd: Strange behaviour in zsh's emacs bindings
- Date: Sat, 17 Jan 2009 01:12:49 -0500 (EST)
- In-reply-to: <FDA87154-BE6A-41AC-A363-6AC0535C458E@xxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <01A495DF-6251-4ED8-863C-C3ECBFA6DE9E@xxxxxxxxxxx> <FDA87154-BE6A-41AC-A363-6AC0535C458E@xxxxxxxxx>
On Sat, 17 Jan 2009, Ludvig Ericson wrote:
Begin forwarded message:
From: Ludvig Ericson <ludvig@xxxxxxxxxxx>
On Jan 17, 2009, at 05:16, Benjamin R. Haskell wrote:
[... example of WORDCHARS affecting '^W' behavior ...]
Sorry for my incompetence in using my own mail client.
No worries. :-)
At risk of hijacking this thread, I'm now puzzled. The behavior above
simply doesn't occur for me.
I might add that I use vi keys, does that matter? I might also add that
if I do dW in normal mode, it deletes ${WORDCHAR}s as well. But not
using ^W.
Yep. Vi keys'll affect it.
## emacs mode
$ bindkey -e
$ bindkey "^W"
"^W" backward-kill-word
## vi mode
$ bindkey -v
$ bindkey "^W"
"^W" vi-backward-kill-word
Looking at the source, (Src/Zle/zle_word.c), it appears emacsbackwardword
uses the following algorithm:
Scan backwards until you hit something that matches: ZC_iword().
Then scan backwards until you hit something that matches: !ZC_iword().
vibackwardword, on the other hand, does:
Scan backwards until you hit something that matches: !ZC_iblank().
If that something matches Z_vialnum():
Scan backwards until you match: !Z_vialnum()
Otherwise:
Scan backwards until you match: Z_vialnum() or ZC_iblank().
So:
emacs-mode will kill any sequence of non-wordchars, then a
(possibly-empty) sequence of wordchars.
vi-mode will kill any sequence of "blank" characters, then:
1. a sequence of alphanumerics, or 2. a sequence of non-blank,
non-alphanumerics
The documentation points this out. (man zshle). The 'vi-' prefixed widgets
treat words as "a series of non-blank characters".
If you want to work around it you can specifically bind "^W" to the
emacs-y version:
bindkey "^W" backward-kill-word
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author