Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Select Whole, When There are Multiple Lines



I did not notice it earlier. The following also works.
....
_select-whole() {
    zle beginning-of-buffer-or-history
    ((REGION_ACTIVE)) || zle set-mark-command
    zle end-of-buffer-or-history
}

zle -N _select-whole
bindkey '^A' _select-whole
....
However, it works weirdly when used on single line.

What can I do so that _select-whole works on both single and multi-lines?

Thanks and Best Regards,
Ahmad Ismail

On Sun, Sep 26, 2021 at 7:08 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Ahmad Ismail wrote on Sat, 25 Sep 2021 11:29 +00:00:
> > I mean when there are multiple lines on the prompt, the keybinding
> > only works for the line where the cursor is. How can I select all
> > lines using ctrl-A
>
> This works:
>
> f() { MARK=0; CURSOR=$#BUFFER; REGION_ACTIVE=1; }
> zle -N f
> bindkey '^T' f
> echo foo^V^Jecho bar^T    # In this line, ^X means to press Ctrl+X
>
> It doesn't work in some other cases.  It works when $BUFFER is
> multiline and $PREBUFFER is empty, but it doesn't work when $BUFFER is
> single-line and the previous content is in $PREBUFFER.  You might be
> able to simulate that with 'P' ranges in region_highlight and
> overriding widgets that operate on the region, but it might be easier
> to just use edit-command-line.




Messages sorted by: Reverse Date, Date, Thread, Author