JAM
JAM

Reputation: 781

characters randomly showing up on screen when move the cursor from left to right in vim insert mode

i have Vim with plugin vim-go and neocomplete, when o move the cursor from left to right in insert mode this happens

Note: this only happens with go code and vim-go required binaries (such as gocode, godef, goimports, etc..)

someone have same problem?

i am running Ubuntu 14.04.2 LTS 64bits with Kernel 3.13.0-48 Vim 7.4.52 with lua support

thanks in advance

Upvotes: 2

Views: 2899

Answers (2)

JAM
JAM

Reputation: 781

I changed from neocomplete to YouCompleteMe, the random characters is not showing anymore.

Upvotes: 0

Thomas Dickey
Thomas Dickey

Reputation: 54505

It looks as if you are using gnome-terminal or konsole.

When you use cursor-keys to move around in insert-mode, the keys send escape sequences. In particular, if you happen to press the shift- or control-keys, those can send different escape sequences (with numbers), possibly with semicolons to separate the numbers. There are some limitations on vim's handling strings of that sort, and in some cases (see this discussion) it will get confused and stop interpreting the string, leaving junk on the screen.

The root of the problem is that in vi, the program (mis)uses the escape character for two different reasons:

  • a special "command" character sent by the user to the editor
  • the first character in the strings sent by most special keys to an application (including an editor).

The latter requires the program (vim) to wait "a while" to determine which case to use. If you are using a slow machine (or a slow connection) and your keyboard-repeat is fast, that defeats vim's attempt to distinguish the two cases. Likewise, your plugins send many characters to the screen for each keystroke, making vim slower.

It is aggravated by modified keys (using shift- or control-modifiers) since xterm and other terminals encode that information as a number. gnome-terminal and konsole use an older variant of xterm's (see xterm FAQ How can I use shift- or control-modifiers?) which is more easily mistaken by vim as not being an escape sequence.

If it is only a matter of timing, then moving your cursor more slowly would avoid the problem (agreeing that is only a workaround). You can gauge the amount of output done by vim by running it in script to capture the output into a typescript file. I do that to analyze bugs, by sending the data back to the terminal more slowly. Some of those typescript files are surprisingly large, for the little apparent work done.

Upvotes: 3

Related Questions