Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
- X-seq: zsh-users 21689
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Filipe Silva <filipe.silva@xxxxxxxxx>
- Subject: Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
- Date: Wed, 22 Jun 2016 01:10:47 +0200
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1466550648; bh=otXEfvkMBl9h+A1F3AmWvPXnbTbJEqn6Da566+lqeso=; h=cc:In-reply-to:From:References:To:Subject:Date:From:Subject; b=OD7jB3iYVVOBpo4/6lnqd2YXaV7CWulC2ShDDJWWC8psg4iAtXCI2wYQmHe9IgFfmt+yLhoCZxUyb/2iaIUo0Ed9fujbsbcpvZmRxFfaoLbfBIicteF1wXoFKiU0O8VlPqyKLgq2X472J91OHtfAA/bdazmbFSCjBvrmx9wDEk9eibtTKN0xcSccih7esmo6AToo3WCjbVFlUohKduNCRDTwMSfser4x4GLhAaRH5fpgo2saCF5CxR2HD2b7HKW4YuC3YzmM3lFJzkl5/zB0xPAkoBrHV9wedOmYImxDqecbpl+nKvmpj0EA6qyoY2RC8RzNXv6FHJHL5HUroFd8bg==
- In-reply-to: <CAEwkUWMnBO7_6EOo5y5b1eMAZB6uXkgXsh51OqtuEbbUQQPRyQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAEwkUWMnBO7_6EOo5y5b1eMAZB6uXkgXsh51OqtuEbbUQQPRyQ@mail.gmail.com>
Filipe Silva wrote:
>
> I reckon there's already a widget for the `g~` action in zle.
Yes, vi-oper-swap-case
> I read the zshzle manual and did not find a widget that would give me the
> behaviour of `gU` (capitalize action)
I use the following custom widgets.
Perhaps these should be included somehow - any thoughts? It might be
easiest in C because with included widgets you still need zle -N and
bindkeys in your .zshrc.
> Is this a matter of writing a custom widget, or would one have to submit a
> patch upstream with c code changes? I'm asking this because 5.0.8
> introduced text objects and that was done via c code changes and not via
> widgets. And writing custom widgets seems to be less difficult.
Some of the text objects were done via shell widgets - select-quoted and
select-bracketed which select text between delimiters. This does mean
you have to enable them yourself. At first, I had hoped they would serve
as examples of how to do text object widgets but they ended up being
quite complex once vim compatibility for odd cases was considered. So
maybe they should be converted to C?
Oliver
vi-lowercase() {
local save_cut="$CUTBUFFER" save_cur="$CURSOR"
zle .vi-change || return
zle .vi-cmd-mode
CUTBUFFER="${CUTBUFFER:l}"
zle .vi-put-after -n 1
CUTBUFFER="$save_cut" CURSOR="$save_cur"
}
vi-uppercase() {
local save_cut="$CUTBUFFER" save_cur="$CURSOR"
zle .vi-change || return
zle .vi-cmd-mode
CUTBUFFER="${CUTBUFFER:u}"
zle .vi-put-after -n 1
CUTBUFFER="$save_cut" CURSOR="$save_cur"
}
zle -N vi-lowercase
zle -N vi-uppercase
bindkey -a 'gU' vi-uppercase
bindkey -a 'gu' vi-lowercase
bindkey -M visual 'u' vi-lowercase
bindkey -M visual 'U' vi-uppercase
Messages sorted by:
Reverse Date,
Date,
Thread,
Author