zsh-users
 help / color / mirror / code / Atom feed
* Emulating vim's Ctrl-W behavior
@ 2013-10-04 21:20 Jack O'Connor
  2013-10-04 22:03 ` Matt Garriott
  0 siblings, 1 reply; 5+ messages in thread
From: Jack O'Connor @ 2013-10-04 21:20 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

Zsh likes to nuke my pipes when I delete backwards. For example, if I have
the line...

echo a | grep

...and I press Ctrl-W twice, then what I'd like to have (and what vim and
bash give me) is...

echo a

But zsh doesn't seem to count the pipe as a word, and the second Ctrl-W
plows through it and deletes the "a". Is there any way to configure zsh to
get vim's behavior? And related, is there a way to delete backwards to the
next slash in a path, as Ctrl-W does in vim, rather than deleting the whole
path? Thanks very much.

-- Jack O'Connor

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emulating vim's Ctrl-W behavior
  2013-10-04 21:20 Emulating vim's Ctrl-W behavior Jack O'Connor
@ 2013-10-04 22:03 ` Matt Garriott
  2013-10-04 23:19   ` Jack O'Connor
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Garriott @ 2013-10-04 22:03 UTC (permalink / raw)
  To: Jack O'Connor; +Cc: zsh-users

Hi Jack,

If you use zsh's vi edit mode (instead of emacs mode) you will get this
behavior by default.

You can set your shell to use vi mode with this command.
  bindkey -v

This will set your shell's line editing mode to vi-style.

You can get more info with:
  man zshzle

-Matt

On Fri, Oct 04, 2013 at 02:20:57PM -0700, Jack O'Connor wrote:
> Zsh likes to nuke my pipes when I delete backwards. For example, if I have
> the line...
> 
> echo a | grep
> 
> ...and I press Ctrl-W twice, then what I'd like to have (and what vim and
> bash give me) is...
> 
> echo a
> 
> But zsh doesn't seem to count the pipe as a word, and the second Ctrl-W
> plows through it and deletes the "a". Is there any way to configure zsh to
> get vim's behavior? And related, is there a way to delete backwards to the
> next slash in a path, as Ctrl-W does in vim, rather than deleting the whole
> path? Thanks very much.
> 
> -- Jack O'Connor


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emulating vim's Ctrl-W behavior
  2013-10-04 22:03 ` Matt Garriott
@ 2013-10-04 23:19   ` Jack O'Connor
  2013-10-05  4:30     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Jack O'Connor @ 2013-10-04 23:19 UTC (permalink / raw)
  To: Matt Garriott; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1328 bytes --]

Awesome, and thanks for the quick response! I was using a mix of bindings
from the emacs and vi modes, and I'd ended up with the emacs version of
Ctrl-W without realizing they were different. I ended up using "bindkey
'^W' vi-backward-kill-word".

-- Jack


On Fri, Oct 4, 2013 at 3:03 PM, Matt Garriott <matt.garriott@gmail.com>wrote:

> Hi Jack,
>
> If you use zsh's vi edit mode (instead of emacs mode) you will get this
> behavior by default.
>
> You can set your shell to use vi mode with this command.
>   bindkey -v
>
> This will set your shell's line editing mode to vi-style.
>
> You can get more info with:
>   man zshzle
>
> -Matt
>
> On Fri, Oct 04, 2013 at 02:20:57PM -0700, Jack O'Connor wrote:
> > Zsh likes to nuke my pipes when I delete backwards. For example, if I
> have
> > the line...
> >
> > echo a | grep
> >
> > ...and I press Ctrl-W twice, then what I'd like to have (and what vim and
> > bash give me) is...
> >
> > echo a
> >
> > But zsh doesn't seem to count the pipe as a word, and the second Ctrl-W
> > plows through it and deletes the "a". Is there any way to configure zsh
> to
> > get vim's behavior? And related, is there a way to delete backwards to
> the
> > next slash in a path, as Ctrl-W does in vim, rather than deleting the
> whole
> > path? Thanks very much.
> >
> > -- Jack O'Connor
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emulating vim's Ctrl-W behavior
  2013-10-04 23:19   ` Jack O'Connor
@ 2013-10-05  4:30     ` Bart Schaefer
  2013-10-05 12:00       ` Valodim Skywalker
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2013-10-05  4:30 UTC (permalink / raw)
  To: zsh-users

On Oct 4,  4:19pm, Jack O'Connor wrote:
} 
} Awesome, and thanks for the quick response! I was using a mix of bindings
} from the emacs and vi modes, and I'd ended up with the emacs version of
} Ctrl-W without realizing they were different.

If you want more control over the emacs backward-kill-word, have a look
at the WORDCHARS variable.  (To which you'd want to add "|", in the
example you gave, and remove "/".)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emulating vim's Ctrl-W behavior
  2013-10-05  4:30     ` Bart Schaefer
@ 2013-10-05 12:00       ` Valodim Skywalker
  0 siblings, 0 replies; 5+ messages in thread
From: Valodim Skywalker @ 2013-10-05 12:00 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 78 bytes --]

If you want full control, look up select-word-style in man zshcontrib.

 - V


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-05 12:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-04 21:20 Emulating vim's Ctrl-W behavior Jack O'Connor
2013-10-04 22:03 ` Matt Garriott
2013-10-04 23:19   ` Jack O'Connor
2013-10-05  4:30     ` Bart Schaefer
2013-10-05 12:00       ` Valodim Skywalker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).