Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having a strange problem with Vim, screen and putty.

I am connecting to Screen through Putty, which, in general, works fine. I have had some issues with getting scrolling to work in Vim, however.

Some details:

  • I set termcapinfo xterm* ti@:te@ in my screenrc so that I can use the mousewheel to scroll. It doesn't work great (scrollback gets muddled between screen windows), but I prefer it to using the keyboard
  • I have set term=xterm in my vimrc.
  • Also in my vimrc, I have set mouse=a and ttymouse=xterm2, so that I can use the mousewheel. This is where problems arise
    • When I scroll with the mouse in the left side of the PuTTY window, it works fine
    • When I scroll with the mouse in the right side of the PuTTY window, random characters either get inserted into the file I'm editing, or into the Vim command line.

I can't find anyone else with this problem when I've searched, and I'm at a loss for things to try. Any suggestions as to what I could try would be really useful.

Let me know if I can provide any more information.

share|improve this question
    
Are the strange characters gone when you type ctrl-L (redraw screen)? –  ott-- Jul 13 '12 at 11:08
    
No, they remain - they also get saved to disk if I save the file. –  Adam Tonks Jul 13 '12 at 15:08
    
I believe this question could be considered a duplicate of this. –  suvayu Jul 23 '12 at 17:35
    
Hey @AdamTonks, having the same issue, any resolution? –  Horak yesterday
    
@Horak Sorry - don't think I ever got this fixed. Ended up going a different direction, and using tmux rather than screen. –  Adam Tonks 16 hours ago
add comment

1 Answer

Putting "set term=xterm" in your vimrc is a bad idea, and probably the cause of your problems; when running under screen, your TERM (on the shell) and the 'term' option in Vim should be "screen" and nothing else.

If you were trying to solve a problem with TERM by setting the 'term' option in Vim, you need to find the actual source of the problem and fix it there. Is PuTTY emulating the right terminal type? Is your shell before you start screen reflecting the proper TERM? (echo $TERM on the shell command-line). And, finally, is your shell after you start screen set to "screen" (as it always should be)?

If you still have this problem after you've corrected the TERM issues, check the output of:

:verbose set ttimeout? ttimeoutlen?

(Note the double t's, and the question marks are part of the command.)

Normally the output would be "nottimeout ttimeoutlen=-1" on two lines, if they're anything else, try resetting them:

:set ttimeout& ttimeoutlen&
share|improve this answer
1  
I guess I should say that unconditionally setting 'term' in your vimrc is a bad idea. I personally set 'term' to xterm-256color if my 'term' is "xterm" and $COLORTERM in my environment is "gnome-terminal". –  Heptite Jul 13 '12 at 22:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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