zsh-users
 help / color / mirror / code / Atom feed
* [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
@ 2016-06-21 18:51 Filipe Silva
  2016-06-21 23:10 ` Oliver Kiddle
  0 siblings, 1 reply; 15+ messages in thread
From: Filipe Silva @ 2016-06-21 18:51 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 917 bytes --]

Hi good people,

I reckon there's already a widget for the `g~` action in zle.

I'm using zsh 5.0.8.

I read the zshzle manual and did not find a widget that would give me the
behaviour of `gU` (capitalize action)

for example: for the word "path_variable", with the cursor on the `v`, gUiW
would change the world to "PATH_VARIABLE", and so on and so forth.

the widget `capitalize-word` does not seem to work like that.

I also found that the key `U` in visual mode does not capitalize the
visually selected text/region. I did not find a widget in the manual that
would give me the desired behaviour either.

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.

Thanks in advance.

Filipe.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-21 18:51 [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode Filipe Silva
@ 2016-06-21 23:10 ` Oliver Kiddle
  2016-06-22  6:42   ` Bart Schaefer
  0 siblings, 1 reply; 15+ messages in thread
From: Oliver Kiddle @ 2016-06-21 23:10 UTC (permalink / raw)
  To: Filipe Silva; +Cc: zsh-users

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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-21 23:10 ` Oliver Kiddle
@ 2016-06-22  6:42   ` Bart Schaefer
  2016-06-22 13:19     ` Filipe Silva
  0 siblings, 1 reply; 15+ messages in thread
From: Bart Schaefer @ 2016-06-22  6:42 UTC (permalink / raw)
  To: zsh-users

On Jun 22,  1:10am, Oliver Kiddle wrote:
}
} Some of the text objects were done via shell widgets - select-quoted and
} select-bracketed which select text between delimiters.

Incidentally, I think select-bracketed might break given ksharrays --
select-quoted explictly turns ksharrays off.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22  6:42   ` Bart Schaefer
@ 2016-06-22 13:19     ` Filipe Silva
  2016-06-22 13:23       ` Filipe Silva
  0 siblings, 1 reply; 15+ messages in thread
From: Filipe Silva @ 2016-06-22 13:19 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 910 bytes --]

Hi Oliver, thanks for sharing the widgets. You should know that there's a
bug in both widgets in an edge case:

suppose you have the word `abc` and `a` is the first char of the line. also
suppose you've select just the `ab` of the `abc` word and then hit `U`:


```
# [ab] is the visually selected text

$ [ab]c
```

after you hit `U` the result is

```
$ cAB
```

I've fixed the bug including the following condition:

if [[ $save_cur = '1' ]]; then
    zle .vi-put-before -n 1
  else
    zle .vi-put-after -n 1
  fi



On Wed, Jun 22, 2016 at 3:42 AM, Bart Schaefer <schaefer@brasslantern.com>
wrote:

> On Jun 22,  1:10am, Oliver Kiddle wrote:
> }
> } Some of the text objects were done via shell widgets - select-quoted and
> } select-bracketed which select text between delimiters.
>
> Incidentally, I think select-bracketed might break given ksharrays --
> select-quoted explictly turns ksharrays off.
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 13:19     ` Filipe Silva
@ 2016-06-22 13:23       ` Filipe Silva
  2016-06-22 15:09         ` Oliver Kiddle
  0 siblings, 1 reply; 15+ messages in thread
From: Filipe Silva @ 2016-06-22 13:23 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2095 bytes --]

Now that 5.0.8 and text objects were mentioned, I think there's a bug with
the `surround` widget. Or maybe just the usage instructions are incorrect.

here are the usage instructions of the `surround` widget on zsh master:

https://github.com/zsh-users/zsh/blob/master/Functions/Zle/surround#L4-L12

# Implementation of some functionality of the popular vim surround plugin.
# Allows "surroundings" to be changes: parentheses, brackets and quotes.

# To use
#   autoload -Uz surround
#   zle -N delete-surround surround
#   zle -N add-surround surround
#   zle -N change-surround surround
#   bindkey -a cs change-surround
#   bindkey -a ds delete-surround
#   bindkey -a ys add-surround
#   bindkey -M visual S add-surround


If I add this to my vi-mode zsh plugin, it does nothing.

for instance, the `ys` chord is not being picked up.

supose i have a word: `abcde` and the cursor is in `c`. if I'm in
normal mode and type `ys` zle thinks that I've hit `s` and deletes the
`c` character and puts me in insert mode.

Maybe it's a bug?


On Wed, Jun 22, 2016 at 10:19 AM, Filipe Silva <filipe.silva@gmail.com>
wrote:

> Hi Oliver, thanks for sharing the widgets. You should know that there's a
> bug in both widgets in an edge case:
>
> suppose you have the word `abc` and `a` is the first char of the line.
> also suppose you've select just the `ab` of the `abc` word and then hit
> `U`:
>
>
> ```
> # [ab] is the visually selected text
>
> $ [ab]c
> ```
>
> after you hit `U` the result is
>
> ```
> $ cAB
> ```
>
> I've fixed the bug including the following condition:
>
> if [[ $save_cur = '1' ]]; then
>     zle .vi-put-before -n 1
>   else
>     zle .vi-put-after -n 1
>   fi
>
>
>
> On Wed, Jun 22, 2016 at 3:42 AM, Bart Schaefer <schaefer@brasslantern.com>
> wrote:
>
>> On Jun 22,  1:10am, Oliver Kiddle wrote:
>> }
>> } Some of the text objects were done via shell widgets - select-quoted and
>> } select-bracketed which select text between delimiters.
>>
>> Incidentally, I think select-bracketed might break given ksharrays --
>> select-quoted explictly turns ksharrays off.
>>
>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 13:23       ` Filipe Silva
@ 2016-06-22 15:09         ` Oliver Kiddle
  2016-06-22 15:25           ` Filipe Silva
  2016-06-22 19:10           ` Filipe Silva
  0 siblings, 2 replies; 15+ messages in thread
From: Oliver Kiddle @ 2016-06-22 15:09 UTC (permalink / raw)
  To: Filipe Silva; +Cc: zsh-users

Filipe Silva wrote:
> for instance, the `ys` chord is not being picked up.
>
> supose i have a word: `abcde` and the cursor is in `c`. if I'm in
> normal mode and type `ys` zle thinks that I've hit `s` and deletes the
> `c` character and puts me in insert mode.
>
> Maybe it's a bug?

I think this occurs if you don't type ys fast enough. What have you got
$KEYTIMEOUT set to? Try typing the ys especially fast. And perhaps try
binding ys to something that will be obvious like kill-whole-line to see
if it is surround that is failing or the key binding.

If this is the problem, it has also been fixed in newer versions by
making it continue waiting for further keys if the keys typed so far,
such as y, correspond to a widget, such as vi-yank, that needs to wait
for a movement. This also allows tricks like
  bindkey -a -s 'cw' 'dwi'
to work much as the equivalent vi map.

Similarly, I can define
  bindkey -s -a "gUU" "gUgU"
but because vi-uppercase is not a builtin widget, I need to hit the keys
fast even in 5.2.

> On Wed, Jun 22, 2016 at 10:19 AM, Filipe Silva <filipe.silva@gmail.com>
> wrote:
> > I've fixed the bug including the following condition:

Thanks for that!

Oliver


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 15:09         ` Oliver Kiddle
@ 2016-06-22 15:25           ` Filipe Silva
  2016-06-22 15:28             ` Filipe Silva
  2016-06-22 19:10           ` Filipe Silva
  1 sibling, 1 reply; 15+ messages in thread
From: Filipe Silva @ 2016-06-22 15:25 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]

Hum, I had this as the first lines of my plugin

# no delays for mode switching.
export KEYTIMEOUT=1

https://github.com/ninrod/nin-vi-mode/blob/master/nin-vi-mode.plugin.zsh#L1-L2

I guess I would have to type really fast for `ys` to work with this
configuration.


On Wed, Jun 22, 2016 at 12:09 PM, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:

> Filipe Silva wrote:
> > for instance, the `ys` chord is not being picked up.
> >
> > supose i have a word: `abcde` and the cursor is in `c`. if I'm in
> > normal mode and type `ys` zle thinks that I've hit `s` and deletes the
> > `c` character and puts me in insert mode.
> >
> > Maybe it's a bug?
>
> I think this occurs if you don't type ys fast enough. What have you got
> $KEYTIMEOUT set to? Try typing the ys especially fast. And perhaps try
> binding ys to something that will be obvious like kill-whole-line to see
> if it is surround that is failing or the key binding.
>
> If this is the problem, it has also been fixed in newer versions by
> making it continue waiting for further keys if the keys typed so far,
> such as y, correspond to a widget, such as vi-yank, that needs to wait
> for a movement. This also allows tricks like
>   bindkey -a -s 'cw' 'dwi'
> to work much as the equivalent vi map.
>
> Similarly, I can define
>   bindkey -s -a "gUU" "gUgU"
> but because vi-uppercase is not a builtin widget, I need to hit the keys
> fast even in 5.2.
>
> > On Wed, Jun 22, 2016 at 10:19 AM, Filipe Silva <filipe.silva@gmail.com>
> > wrote:
> > > I've fixed the bug including the following condition:
>
> Thanks for that!
>
> Oliver
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 15:25           ` Filipe Silva
@ 2016-06-22 15:28             ` Filipe Silva
  2016-06-22 22:29               ` Oliver Kiddle
  0 siblings, 1 reply; 15+ messages in thread
From: Filipe Silva @ 2016-06-22 15:28 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2137 bytes --]

Oliver,


"If this is the problem, it has also been fixed in newer versions by
making it continue waiting for further keys if the keys typed so far,
such as y, correspond to a widget, such as vi-yank, that needs to wait
for a movement. This also allows tricks like
  bindkey -a -s 'cw' 'dwi'
to work much as the equivalent vi map."

What recent versions would those be? since 5.2?

cheers,

Filipe

On Wed, Jun 22, 2016 at 12:25 PM, Filipe Silva <filipe.silva@gmail.com>
wrote:

> Hum, I had this as the first lines of my plugin
>
> # no delays for mode switching.
> export KEYTIMEOUT=1
>
>
> https://github.com/ninrod/nin-vi-mode/blob/master/nin-vi-mode.plugin.zsh#L1-L2
>
> I guess I would have to type really fast for `ys` to work with this
> configuration.
>
>
> On Wed, Jun 22, 2016 at 12:09 PM, Oliver Kiddle <okiddle@yahoo.co.uk>
> wrote:
>
>> Filipe Silva wrote:
>> > for instance, the `ys` chord is not being picked up.
>> >
>> > supose i have a word: `abcde` and the cursor is in `c`. if I'm in
>> > normal mode and type `ys` zle thinks that I've hit `s` and deletes the
>> > `c` character and puts me in insert mode.
>> >
>> > Maybe it's a bug?
>>
>> I think this occurs if you don't type ys fast enough. What have you got
>> $KEYTIMEOUT set to? Try typing the ys especially fast. And perhaps try
>> binding ys to something that will be obvious like kill-whole-line to see
>> if it is surround that is failing or the key binding.
>>
>> If this is the problem, it has also been fixed in newer versions by
>> making it continue waiting for further keys if the keys typed so far,
>> such as y, correspond to a widget, such as vi-yank, that needs to wait
>> for a movement. This also allows tricks like
>>   bindkey -a -s 'cw' 'dwi'
>> to work much as the equivalent vi map.
>>
>> Similarly, I can define
>>   bindkey -s -a "gUU" "gUgU"
>> but because vi-uppercase is not a builtin widget, I need to hit the keys
>> fast even in 5.2.
>>
>> > On Wed, Jun 22, 2016 at 10:19 AM, Filipe Silva <filipe.silva@gmail.com>
>> > wrote:
>> > > I've fixed the bug including the following condition:
>>
>> Thanks for that!
>>
>> Oliver
>>
>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 15:09         ` Oliver Kiddle
  2016-06-22 15:25           ` Filipe Silva
@ 2016-06-22 19:10           ` Filipe Silva
  2016-06-22 20:11             ` Oliver Kiddle
  2016-06-22 20:19             ` Bart Schaefer
  1 sibling, 2 replies; 15+ messages in thread
From: Filipe Silva @ 2016-06-22 19:10 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]

Oliver, (and for whoever is interested in these widgets)

Just a small update on the fix. the correct condition is as follows (the
other that I've gave you also contains a bug).

if [[ $CURSOR = '0' ]]; then
   zle .vi-put-before -n 1
else
   zle .vi-put-after -n 1
fi

updated plugin section:
https://github.com/ninrod/nin-vi-mode/blob/master/nin-vi-mode.plugin.zsh#L126-L130

cheers and thanks again.



On Wed, Jun 22, 2016 at 12:09 PM, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:

> Filipe Silva wrote:
> > for instance, the `ys` chord is not being picked up.
> >
> > supose i have a word: `abcde` and the cursor is in `c`. if I'm in
> > normal mode and type `ys` zle thinks that I've hit `s` and deletes the
> > `c` character and puts me in insert mode.
> >
> > Maybe it's a bug?
>
> I think this occurs if you don't type ys fast enough. What have you got
> $KEYTIMEOUT set to? Try typing the ys especially fast. And perhaps try
> binding ys to something that will be obvious like kill-whole-line to see
> if it is surround that is failing or the key binding.
>
> If this is the problem, it has also been fixed in newer versions by
> making it continue waiting for further keys if the keys typed so far,
> such as y, correspond to a widget, such as vi-yank, that needs to wait
> for a movement. This also allows tricks like
>   bindkey -a -s 'cw' 'dwi'
> to work much as the equivalent vi map.
>
> Similarly, I can define
>   bindkey -s -a "gUU" "gUgU"
> but because vi-uppercase is not a builtin widget, I need to hit the keys
> fast even in 5.2.
>
> > On Wed, Jun 22, 2016 at 10:19 AM, Filipe Silva <filipe.silva@gmail.com>
> > wrote:
> > > I've fixed the bug including the following condition:
>
> Thanks for that!
>
> Oliver
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 19:10           ` Filipe Silva
@ 2016-06-22 20:11             ` Oliver Kiddle
  2016-06-22 20:19             ` Bart Schaefer
  1 sibling, 0 replies; 15+ messages in thread
From: Oliver Kiddle @ 2016-06-22 20:11 UTC (permalink / raw)
  To: Filipe Silva; +Cc: zsh-users

Filipe Silva wrote:
>
> Just a small update on the fix. the correct condition is as follows (the
> other that I've gave you also contains a bug).
>
> if [[ $CURSOR = '0' ]]; then

I've just noticed that we also need to account for the cursor being at
the beginning of a line other than the first one so the correct
condition is:
    if [[ CURSOR -eq 0 || $BUFFER[CURSOR] = $'\n' ]]; then

Oliver


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 19:10           ` Filipe Silva
  2016-06-22 20:11             ` Oliver Kiddle
@ 2016-06-22 20:19             ` Bart Schaefer
  1 sibling, 0 replies; 15+ messages in thread
From: Bart Schaefer @ 2016-06-22 20:19 UTC (permalink / raw)
  To: zsh-users

On Jun 22,  4:10pm, Filipe Silva wrote:
}
} if [[ $CURSOR = '0' ]]; then
}    zle .vi-put-before -n 1
} else
}    zle .vi-put-after -n 1
} fi

This would more commonly be written using (( math )), e.g.:

  if (( CURSOR )); then
    zle .vi-put-after -n 1
  else
    zle .vi-put-before -n 1
  fi

Does that cover the situation where initially CURSOR > 0 but the motion
applied extends leftward to the beginning of the line?


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 15:28             ` Filipe Silva
@ 2016-06-22 22:29               ` Oliver Kiddle
  2016-06-23  4:30                 ` Filipe Silva
  0 siblings, 1 reply; 15+ messages in thread
From: Oliver Kiddle @ 2016-06-22 22:29 UTC (permalink / raw)
  To: Filipe Silva; +Cc: zsh-users

Filipe Silva wrote:
>
> "If this is the problem, it has also been fixed in newer versions by
> making it continue waiting for further keys if the keys typed so far,

> What recent versions would those be? since 5.2?

Actually, the change was made in December 2014 - before 5.0.8. However,
looking at your setup, it seems that you have in effect the following:
  cutbuffer() {
    zle .$WIDGET
    echo $CUTBUFFER | pbcopy
  }
  zle -N vi-yank cutbuffer

The custom cutbuffer widget is not marked as being a vi operator so gets
invoked as soon as you press y. Currently, I can't think of an easy fix
for this. In the past, we considered allowing flags to be set on custom
widgets and I also pondered having a separate ESCKEYTIMEOUT variable.

As an aside, you might want to guard against $CUTBUFFER starting with a
- or containing \ escapes. Consider using printf or print -r --. Or
perhaps pbcopy <<<"$CUTBUFFER"

Oliver


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-22 22:29               ` Oliver Kiddle
@ 2016-06-23  4:30                 ` Filipe Silva
  2016-06-23  5:28                   ` Bart Schaefer
  2016-06-23 22:37                   ` Bart Schaefer
  0 siblings, 2 replies; 15+ messages in thread
From: Filipe Silva @ 2016-06-23  4:30 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

Oliver,

thanks for pointing out the issue.

Having an ESCKEYTIMEOUT would be awesome. Setting KEYTIMEOUT to anything
above 5 is quite noticeable and laggy when I want to return to normal mode.
KEYTIMEOUT=1 is snappy, but then I lose out on the surround widget and
whatnot because I can't type `ys` fast enough.

On Wed, Jun 22, 2016 at 7:29 PM, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:

> Filipe Silva wrote:
> >
> > "If this is the problem, it has also been fixed in newer versions by
> > making it continue waiting for further keys if the keys typed so far,
>
> > What recent versions would those be? since 5.2?
>
> Actually, the change was made in December 2014 - before 5.0.8. However,
> looking at your setup, it seems that you have in effect the following:
>   cutbuffer() {
>     zle .$WIDGET
>     echo $CUTBUFFER | pbcopy
>   }
>   zle -N vi-yank cutbuffer
>
> The custom cutbuffer widget is not marked as being a vi operator so gets
> invoked as soon as you press y. Currently, I can't think of an easy fix
> for this. In the past, we considered allowing flags to be set on custom
> widgets and I also pondered having a separate ESCKEYTIMEOUT variable.
>
> As an aside, you might want to guard against $CUTBUFFER starting with a
> - or containing \ escapes. Consider using printf or print -r --. Or
> perhaps pbcopy <<<"$CUTBUFFER"
>
> Oliver
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-23  4:30                 ` Filipe Silva
@ 2016-06-23  5:28                   ` Bart Schaefer
  2016-06-23 22:37                   ` Bart Schaefer
  1 sibling, 0 replies; 15+ messages in thread
From: Bart Schaefer @ 2016-06-23  5:28 UTC (permalink / raw)
  To: zsh-users

On Jun 23,  1:30am, Filipe Silva wrote:
}
} Having an ESCKEYTIMEOUT would be awesome. Setting KEYTIMEOUT to anything
} above 5 is quite noticeable and laggy when I want to return to normal mode.
} KEYTIMEOUT=1 is snappy, but then I lose out on the surround widget and
} whatnot because I can't type `ys` fast enough.

Try this:

    set-keytimeout() {
      case $KEYMAP in
      (vicmd) KEYTIMEOUT=5;;
      (*) KEYTIMEOUT=1;;
      esac
    }
    zle -N zle-keymap-select set-keytimeout
    zle -N zle-line-init set-keytimeout

That should give you a short timeout when switching from insert mode to
what you call "normal mode" (command mode), and a longer one when you
are in command mode.  Sadly, for reasons already noted, it won't speed
up using ESC in command mode for deactivate-region.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode
  2016-06-23  4:30                 ` Filipe Silva
  2016-06-23  5:28                   ` Bart Schaefer
@ 2016-06-23 22:37                   ` Bart Schaefer
  1 sibling, 0 replies; 15+ messages in thread
From: Bart Schaefer @ 2016-06-23 22:37 UTC (permalink / raw)
  To: Zsh Users

[I'm having some trouble connecting to my SMTP server from home,
so I'm pasting this into gmail.  Apologies if the formatting gets weird or
if a nearly-identical message appears later if things suddenly start
working again.]

On Wed, Jun 22, 2016 at 9:30 PM, Filipe Silva <filipe.silva@gmail.com> wrote:
>
> Having an ESCKEYTIMEOUT would be awesome. Setting KEYTIMEOUT to anything
> above 5 is quite noticeable and laggy when I want to return to normal mode.
> KEYTIMEOUT=1 is snappy, but then I lose out on the surround widget and
> whatnot because I can't type `ys` fast enough.

Try this:

    set-keytimeout() {
      case $KEYMAP in
      (vicmd) KEYTIMEOUT=5;;
      (*) KEYTIMEOUT=1;;
      esac
    }
    zle -N zle-keymap-select set-keytimeout
    zle -N zle-line-init set-keytimeout

That should give you a short timeout when switching from insert mode
to what you call "normal mode" (command mode), and a longer one when
you are in command mode.  Sadly, for reasons already noted, it won't
speed up using ESC in command mode for deactivate-region.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-06-25 20:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21 18:51 [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode Filipe Silva
2016-06-21 23:10 ` Oliver Kiddle
2016-06-22  6:42   ` Bart Schaefer
2016-06-22 13:19     ` Filipe Silva
2016-06-22 13:23       ` Filipe Silva
2016-06-22 15:09         ` Oliver Kiddle
2016-06-22 15:25           ` Filipe Silva
2016-06-22 15:28             ` Filipe Silva
2016-06-22 22:29               ` Oliver Kiddle
2016-06-23  4:30                 ` Filipe Silva
2016-06-23  5:28                   ` Bart Schaefer
2016-06-23 22:37                   ` Bart Schaefer
2016-06-22 19:10           ` Filipe Silva
2016-06-22 20:11             ` Oliver Kiddle
2016-06-22 20:19             ` Bart Schaefer

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