I've been using xterm on a KDE desktop for many years, on one Debian/Ubuntu/Arbian release after another. I use the focus-follows-mouse desktop setting, and ":set mouse=a" in .vimrc. Recent releases introduce a misbehavior I don't know how to track down. Seems to have happened Debian 10->11, Buster->Bullseye.

With vim in input mode, when I move the cursor out of the xterm where vim is running (the window loses focus), there is a beep and vim switches to command mode, as if someone had hit esc in that window. The old behavior was to wait quietly until the focus came back on the vi window, so I could paste in whatever I went to the other window to copy.

gvim on the desktop doesn't have this problem.
It happens on an old (buster) desktop talking via ssh to a shell+vim on new (Bullseye) systems.

What's going on here? Is the new shell passing along a signal it used to trap? How to track down?

2 Answers 2


Try adding the following line to your vimrc. (more information: :help xterm-focus-event)

set t_fd= t_fe=

Vim 8.2.2345 adds support for xterm focus event, which are enabled by default.


In my environment, when this new setting is enabled and there is a mapping to esc in insert mode, when the window loses focus, vim switches to command mode as if I had pressed esc.

(I'm not sure if this is a bug or a specification.)


It turns out the issue occurs in "vi" from Debian's vim-tiny package, but not with "vi" from vim-basic or vim-gtk. The reason is vim-tiny installs an /etc/vim/vimrc.tiny with a line "set compatible" not commented out. The others only install /etc/vim/vimrc. This explains the differences in behavior among my installations.

Apparently "vi" from vim-tiny requests those focus change notifications from the terminal, but doesn't know what to do with them. Invoke the same program from the same package by its other name "vim", and it doesn't show the problem.

The quickest fix is to change "set compatible" to "set nocompatible" in /etc/vim/vimrc.tiny.

I got three good answers in the Raspberry Pi forums overnight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.