> I've googled and FAQd and experimented without success. > > When I have the vim editor open in an xterm window, in insert mode, > and move my mouse (and focus) into another window, the vim in the > original window receives some sort of escape sequence that causes > it to leave insert mode and beep.
xterm (and presumably things that immitate it closely enough) can be set to send escape sequences when it gains or loses window keyboard focus: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-FocusIn_FocusOut Apparently vim can be set to automatically do things when this happens, which probably makes it have xterm turn on generating the escape sequences. People use this for things like auto-saving when you move focus away from vim, through what vim apparently calls 'autocmds': https://vim.fandom.com/wiki/Auto_save_files_when_focus_is_lost http://vimdoc.sourceforge.net/htmldoc/autocmd.html I suspect that somewhere in either your vim settings or system-wide vim settings there is something that turns on a FocusLost autocmd. If I'm reading the vim help correctly, I think using ':au FocusLost' in vim should tell you something about the situation. This behavior is unlikely to be visible outside vim (or a specifically crafted environment), because as far as I know xterm must be specifically told to send these escape sequences. Vim (or anything else wanting to do this) normally turns on this sort of escape sequence when it starts and turns them off when it exits (or starts a shell). Unfortunately I don't think there's any way to have xterm tell you (in one of its menus) whether these are enabled or not. It's possible that using ctrl+button-3 to bring up xterm's menu (well, one of them) would let you turn this off to experiment by turning off some combination of 'Allow Mouse Ops' and 'Allow Window Ops' (probably mostly or entirely the former). (To be clear here, this behavior almost certainly has nothing to do with fvwm, unless the Ubuntu 21.04 vim environment you're using does something different depending on the window manager. I would expect this to happen on any window manager or desktop when an xterm with vim inside it loses focus.) - cks