From: Rik <gitaarik@posteo.net>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: Make `Ctrl + W` and `Ctrl + Shift + H` in zsh behave the same as in bash
Date: Sat, 21 Mar 2020 15:12:22 -0500 [thread overview]
Message-ID: <5d798522-f2f7-0017-f62c-e5748eaecdce@posteo.net> (raw)
In-Reply-To: <20200321200611.7e677d21@tarpaulin.shahaf.local2>
Hey Daniel,
Thanks for your explanation!
Yes just using WORDCHARS will work, but that will also change the
behavior of Ctrl + Alt + H. I want that to keep deleting *partial* words.
Greets,
Rik
On 21-03-2020 15:06, Daniel Shahaf wrote:
> Rik wrote on Sat, 21 Mar 2020 14:29 -0500:
>> I've recently started using zsh and I like it. However, coming from
>> bash, some little things I miss.
>>
> Welcome!
>
>> *The problem:*
>>
>> In bash behavior is like this:
>>
>> * Ctrl + W deletes the word behind the cursor up to the next space
>> * Ctrl + Shift + H deletes the word behind the cursor up to the next
>> seperation charcater like ., ,, -, / etc.
>>
>> In zsh both Ctrl + W an Ctrl + Shift + H behave like the latter one in
>> bash. I would like the same behavior as in bash.
>>
>>
>>
>> *This is what I've tried:*
>>
>> SPACE_WORDCHARS='~!#$%^&*(){}[]<>?.+;-_/\|=@`'
>> backward-delete-word() WORDCHARS=$SPACE_WORDCHARS zle .$WIDGET
>> zle -N backward-delete-word
>> bindkey "^W" backward-delete-word
>>
>> This works, however, it breaks the functionality that deleting a word
>> puts the word on the paste buffer, so I can't then paste this word with
>> Ctrl + Y. This is quite important functionality for me. To be honest I'm
>> not completely sure how this zle function works and what .$WIDGET does.
>> Would anyone know a way how I can make this work while retaining the
>> cut/paste behavior?
> Deleting those four lines and adding just «WORDCHARS='~!#$%^&*(){}[]<>?.+;-_/\|=@`'»
> instead seems to do what you want.
>
> (I also tried calling «zle -f kill» in the wrapper but it didn't have
> the desired effect.)
>
> Regarding $WIDGET, it's a parameter that gets predefined by zle when
> widget functions are invoked. In the example, its value will be
> "backward-delete-char". Thus, net effect of «zle .$WIDGET» will be to
> call the builtin "backward-delete-char" widget. For a simpler example,
> consider:
>
> mywidget() { LBUFFER+="x" }
> zle -N mywidget
> bindkey "y" mywidget
>
> With this, every time you press "y", you'll get an "x" inserted. (You
> can just paste this example at the prompt to try it.)
>
> Cheers,
>
> Daniel
prev parent reply other threads:[~2020-03-21 20:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-21 19:29 Rik
2020-03-21 20:06 ` Daniel Shahaf
2020-03-21 20:12 ` Rik [this message]
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d798522-f2f7-0017-f62c-e5748eaecdce@posteo.net \
--to=gitaarik@posteo.net \
--cc=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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
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).