+2  A: 

I'm guessing that the issue might be with your termcap and terminfo settings. Try commenting those out from your screenrc, and restarting screen.

Also, what (non-virtual) terminal are you using?

Ah, it looks like you're using OSX's Terminal.app, which is exactly what I use (with screen/zsh/vim). /usr/bin/screen should work with /usr/bin/vim with an empty .screenrc and .vimrc by default.

% touch empty_screenrc
% cat empty_screerc
% /usr/bin/screen -c empty_screenrc
#...and within screen
% /usr/bin/vim -u NONE

If the problem still persists, the problem may be in your shell. But if this fixes the problem, I'd suggest posting your ~/.vimrc to aid in further diagnosis.

rampion
I commented the lines out. The problem still persists. My non-virtual terminal is apparently xTerm-colour: http://dl.getdropbox.com/u/175564/terminalMode.png .
Masi
+2  A: 
Masi
+2  A: 

I think that the OS X default version of screen does not support 256 colors. You can set vim to use a lower number of colors in your .vimrc file:

set t_Co=16

On Mac OS X you can rebuild screen to use 256 colors, see here: http://pjkh.com/articles/2008/07/09/osx-iterm-screen-vim-256-colors.

Here's the short version of the instructions:

Rebuild screen making sure to include the 256 colors option:

./configure --enable-colors256

Then you will need to add the following to your ~/.screenrc:

# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"

Source

Doug
Good suggestion, but it did not solve the problem, not even in iTerm. I set PATHs correctly and installed the newest the recommended Screen, and enabled 256 color support.
Masi
Scattered windows still occur similarly as before.
Masi
What about changing vim to use fewer than 256 colors? Did that make any difference?
Doug
@Doug: No difference. The same problem still persists.
Masi
+1  A: 
Masi
+1  A: 

It looks like there are some known issues relating to wrap mode for OS X, see number 1. here. It suggests a workaround.

Todd Gardner
@Todd: Thank you for pointing that out! It seems that the same bug is in Vim too, as in MacVim. -- The bug in the question is none in the list.
Masi
A: 

Debugging:

One suggested me to freeze my terminal from the changes of other applications by

ttyctl -f

However, it did not seem to solve the problem. Nevertheless, it may help us to find the bug, since we do not have other apps changing the situation now.

Masi
+1  A: 

I've had similar problems with irssi and bash, which were caused by colour codes not closed correctly..

Have you tried a different vim theme (specifically the default one), or running :syntax off ?

dbr
Thank you for the answer, but the same problem occurs with `syntax off`. I use always the default theme so it is not the problem. --- I have noticed that the problem is not apparently caused by Vim alone. The problem seems to be caused mainly by Screen OR Mac's Terminal.app.
Masi
Oh :( Have you tried iTerm?
dbr