help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "chiasa.men" <chiasa.men@web.de>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: ctrl w behaviour: jump in front of separating characters?
Date: Tue, 24 Aug 2021 15:32:28 -0700	[thread overview]
Message-ID: <CAH+w=7bSY_4YuWSVpdFvOoq24raUFZyKc0T-durHRc8v2KTC5g@mail.gmail.com> (raw)
In-Reply-To: <1669747.SQSiQHpE4G@march>

On Tue, Aug 24, 2021 at 9:04 AM chiasa.men <chiasa.men@web.de> wrote:
> What I actually want is that it goes from
> ls -l -a --color /
> to
> ls -l -a --color
> and after that to
> ls -l -a

Have a look at the backward-kill-word-match widget from Functions/Zle
in the distribution.  The documentation for it is too long to quote
fully here.  I think you want:

autoload backward-kill-word-match
zle -N backward-kill-word backward-kill-word-match
zstyle ':zle:*' subword-range /
zstyle ':zle:*' word-chars ''
zstyle ':zle:*' word-style shell-subword

but there may be cases you haven't enumerated, e.g., for editing
substitutions you might prefer

zstyle ':zle:*' subword-range '][<>{}() /$'

> ls -l -a --color # mind the blank, which is unwanted too
> ls -l -a # that unwanted blank again

That's a bit trickier because an unquoted space is nearly always
considered to be "between" words, there's probably a way to get
backward-word-match to do it but I'll leave that to someone else to
figure out.  Writing your own widget:

backward-kill-word-space() {
  while [[ $LBUFFER = *' ' ]] &&
    zle backward-delete-char
  do :; done
zle -N backward-kill-word backward-kill-word-space

  reply	other threads:[~2021-08-24 22:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 16:04 chiasa.men
2021-08-24 22:32 ` Bart Schaefer [this message]
2021-08-25 18:43   ` Daniel Shahaf
2021-08-25 19:29     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7bSY_4YuWSVpdFvOoq24raUFZyKc0T-durHRc8v2KTC5g@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=chiasa.men@web.de \
    --cc=zsh-users@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).