terminals + tmux + vim: ESC + arrows unexpected behaviour

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

terminals + tmux + vim: ESC + arrows unexpected behaviour

frantisek holop
there seems to be some unexpected behaviour (at least
for me) in terminal vim running under tmux:

pressing ESC and right after that the arrow keys to
move around (vim purist need not comment on this) get
interpreted as different vim commands: for example UP
will enter insert mode again, LEFT, RIGHT send some
deleting commands, DOWN moves the cursor around in
mysterious ways.

reproduced this in these environments:
openbsd -current: urxvt + tmux + vim
openbsd -current: xterm + tmux + vim
osx: iterm2 + tmux 2.4 + vim 8.0.596

could not reproduce this on: openbsd 6.0 release

leaving tmux always fixes the issue, so i am included
to think it might be a tmux issue.  any ideas?

-f
--

Reply | Threaded
Open this post in threaded view
|

Re: terminals + tmux + vim: ESC + arrows unexpected behaviour

Andreas Kusalananda Kähäri
On Sun, May 14, 2017 at 01:54:27PM +0200, frantisek holop wrote:

> there seems to be some unexpected behaviour (at least
> for me) in terminal vim running under tmux:
>
> pressing ESC and right after that the arrow keys to
> move around (vim purist need not comment on this) get
> interpreted as different vim commands: for example UP
> will enter insert mode again, LEFT, RIGHT send some
> deleting commands, DOWN moves the cursor around in
> mysterious ways.
>
> reproduced this in these environments:
> openbsd -current: urxvt + tmux + vim
> openbsd -current: xterm + tmux + vim
> osx: iterm2 + tmux 2.4 + vim 8.0.596
>
> could not reproduce this on: openbsd 6.0 release
>
> leaving tmux always fixes the issue, so i am included
> to think it might be a tmux issue.  any ideas?

tmux has an "escape-time" setting:

    escape-time time
         Set the time in milliseconds for which tmux waits
         after an escape is input to determine if it is part
         of a function or meta key sequences.  The default
         is 500 milliseconds.

You are probably pressing the arrow keys within this timeframe.  Try
decreasing it to something like 100:

    set-option escape-time 100

This worked for me when I had the same issue.

Regards,
Kusalananda

Reply | Threaded
Open this post in threaded view
|

Re: terminals + tmux + vim: ESC + arrows unexpected behaviour

frantisek holop
Andreas Kusalananda Kähäri, 14 May 2017 14:28:

> tmux has an "escape-time" setting:
>
>     escape-time time
>          Set the time in milliseconds for which tmux waits
>          after an escape is input to determine if it is part
>          of a function or meta key sequences.  The default
>          is 500 milliseconds.
>
> You are probably pressing the arrow keys within this timeframe.  Try
> decreasing it to something like 100:
>
>     set-option escape-time 100

thanks, this seems to help.
is there a downside to setting this to 0?

-f
--

Reply | Threaded
Open this post in threaded view
|

Re: terminals + tmux + vim: ESC + arrows unexpected behaviour

Andreas Kusalananda Kähäri
On Sun, May 14, 2017 at 07:12:45PM +0200, frantisek holop wrote:

> Andreas Kusalananda Kähäri, 14 May 2017 14:28:
> > tmux has an "escape-time" setting:
> >
> >     escape-time time
> >          Set the time in milliseconds for which tmux waits
> >          after an escape is input to determine if it is part
> >          of a function or meta key sequences.  The default
> >          is 500 milliseconds.
> >
> > You are probably pressing the arrow keys within this timeframe.  Try
> > decreasing it to something like 100:
> >
> >     set-option escape-time 100
>
> thanks, this seems to help.
> is there a downside to setting this to 0?

Well, I assume it depends on whether you'd like to enter function or
meta key sequences to tmux or not...  If not, then there should be no
downside.

Regards,
Kusalananda