benekastah
benekastah

Reputation: 5711

Vim motion keys sometimes appear on screen when using tmux

When I'm not in insert mode and I'm navigating around my file with the motion keys (hjkl etc), the keys often appear in the buffer (illustrated below). I can observe this effect pretty readily in tmux, but it doesn't seem to happen without. If I run :!reset in vim the buffer returns to normal, but it doesn't stay that way for long. I'm not sure why this is happening and google yielded nothing. Halp?

Edit: It seems just a simple :e will fix the problem, too.

An illustration of the problem

Upvotes: 0

Views: 406

Answers (2)

Jeremy Huiskamp
Jeremy Huiskamp

Reputation: 5294

I experience the same thing. A few extra observations:

  • it only seems to happen when I hold down a motion key like j or k, causing rapid repeats
  • it happens both in and outside of tmux, but much more often in tmux
  • it happens much more often since I enabled vim-go's go_auto_sameids, which I believe is making a call to an external program (guru) for every cursor movement

This leads me to assume that it's a timing issue in vim that is exacerbated by latency added by things like tmux and/or plugins.

(Using gnome terminal; $TERM is screen-256color in tmux and xterm-256color outside)

Upvotes: 1

chepner
chepner

Reputation: 531205

I think this was alluded to on the tmux mailing list recently. Try decreasing the value of the escape-time parameter in tmux, so that tmux more quickly sends the escape character to vim to return to command mode, rather than waiting for more characters in an escape sequence. The default value is 500ms, so try something smaller, like 50.

In .tmux.conf:

set-option -g escape-time 50

Upvotes: 0

Related Questions