1

I ssh to my AWS EC2 machine with Amazon Linux from local Ubuntu with GNOME Terminal. If open vim in the ssh session and then Alt+Tab from terminal to another app and then Alt+Tab back, annoying messages appear: E349: No identifier under cursor or Press ENTER or type command to continue. After some digging I've figured out the reason: weird characters are sent to ssh terminal when I Alt+Tab:

[ec2-user@ip-172-31-43-121 ~]$ cat
^[[O^[[I^[[O^[[I^[[O^[[I^[[O^[[I^[[O^[[I

^[[O^[[I per single Alt+Tab. What do these characters mean? Why are they sent and how to prevent their occurrence?

EDIT: Fixed by restarting GNOME Terminal.

2

That's the terminal sending xterm's focus-in/focus-out escapes. vim's set the terminal into a mode that lets it know when the cursor leaves the window (which it does when alt-tabbing).

You would prevent that by changing the mode used in vim for handling the mouse. Checking xterm's documentation, vim would have to send a particular escape sequence with 1004 parameter (to tell xterm to send those escapes), but I do not see that in vim's source-code. Some other terminal may be doing this as a side-effect of the mouse-movement mode 1003 (which vim does send):

    if (xterm_mouse_vers > 0)
    {
        if (on) // enable mouse events, use mouse tracking if available
            out_str_nf((char_u *)
               (xterm_mouse_vers > 1
            ? (
#ifdef FEAT_BEVAL_TERM
                bevalterm_ison
                   ? IF_EB("\033[?1003h", ESC_STR "[?1003h") :
#endif
                  IF_EB("\033[?1002h", ESC_STR "[?1002h"))
            : IF_EB("\033[?1000h", ESC_STR "[?1000h")));
        else    // disable mouse events, could probably always send the same
            out_str_nf((char_u *)
                   (xterm_mouse_vers > 1
                ? IF_EB("\033[?1002l", ESC_STR "[?1002l")
                : IF_EB("\033[?1000l", ESC_STR "[?1000l")));
        mouse_ison = on;
    }

You probably should consult the user manual of the terminal you are using, to see what the expected behavior would be with vim.

|improve this answer|||||

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.