Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've recently started using ZHS with oh-my-zsh script pack. It does excellent job except of weird ^W shortcut behavior.

For example if I have following command line and symbol ▮ denotes cursor position.

$ ./command_name --option1 value --option2=value ▮

Sequentially pressing ^W for several times I'd get following content in command prompts:

$ ./command_name --option1 value --option2=▮
$ ./command_name --option1 value --▮
$ ./command_name --option1 ▮
$ ./command_name --▮
$ ./command_▮
$ ./▮

What bugs me is that after third press cursor stops not after deleting --, but also eats value. I suspect that all symbols such as "_-" are considered as separators as spaces and zsh continues eating symbols until it deletes some non-separator chars, but I have no idea how to change this behavior.

share|improve this question
UPD: I've tried solutions from here, didn't help:… – Nevkontakte Oct 2 '13 at 7:24
What is echo $WORDCHARS? – slhck Oct 2 '13 at 11:37
Thanks for response. It's empty. – Nevkontakte Oct 2 '13 at 15:07
up vote 1 down vote accepted

In order to fix this (default) behavior you want to have Zsh use vi-style backward-kill-word.

Put this in your ~/.zshrc:

bindkey '^W' vi-backward-kill-word

Now, it will kill to the following positions:

$ ./command_name --option1 value --option2=▮
$ ./command_name --option1 value --option2▮
$ ./command_name --option1 value --▮
$ ./command_name --option1 value ▮
$ ./command_name --option1 ▮
$ ./command_name --▮
$ ./command_name ▮
$ ./▮
$ ▮
share|improve this answer
Worked like a charm, thanks! – Nevkontakte Oct 3 '13 at 8:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.