doukezi4606
doukezi4606
2015-04-07 01:00

在vim插入模式下左右移动光标时,随机出现在屏幕上的字符

已采纳

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • drfu80954 drfu80954 6年前

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

    点赞 评论 复制链接分享
  • douxia6554 douxia6554 6年前

    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.

    点赞 评论 复制链接分享
  • dongting3135 dongting3135 6年前

    This looks to me like your TERM setting is wrong for your terminal.

    If your TERM setting is wrong, you'll often get random garbage on the screen, of this manner.

    Check your TERM environment variable. Verify that it is set correctly for whatever terminal display you're using.

    点赞 评论 复制链接分享