Is your syntax highligting sometimes messed up? Try adding this to your .vimrc:
noremap <f12> <esc>:syntax sync fromstart<cr> inoremap <f12> <c-o>:syntax sync fromstart<cr>
This will let your <f12> key clean it up in most cases.
Redrawing the screen with Ctrl-L helps too.