Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to avoid infinite recursion in ZLE widgets
> On 23 September 2020 at 09:34 Peter Slížik <peter.slizik@xxxxxxxxx> wrote:
> I'd like to replicate the functionality found in some text editors - namely
> that if you press a single or double quote, the editor inserts two of them
> and places the cursor inside the pair.
>
> With some necessary checks for word boundaries, etc. left out, the solution
> looks rather trivial:
>
> function insert-single-quotes() {
> zle self-insert "''" # that's "_'_'_"
> zle backward-char
> }
The right way to insert something into the buffer at this point is using
the special variables. You can add a quote before and a quote after
the cursor using:
insert-single-quotes() {
LBUFFER+="'"
RBUFFER="'$RBUFFER"
}
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author