Skip to content

Weird scrollback behavior after Vim session

In my .vimrc file, I have set mouse=a, and scrolling with the mouse or with the keyboard always works fine while I'm in Vim. Sometimes, when I exit Vim, then scroll back in my terminal command history, I see chunks of my Vim session mixed in with my command history. This happens frequently, but it isn't perfectly reproducible. I was able to catch it while running a debug log (link to file in Google Drive attached). During my Vim session, I scrolled with both the keyboard and with the mouse. Here are some screenshots of the session captured by the debug log:

Immediately after exiting Vim session:

Screen_Shot_2016-09-05_at_8.56.28_AM

After scrolling up half a screen:

Screen_Shot_2016-09-05_at_8.56.43_AM

After scrolling up one full screen from there:

Screen_Shot_2016-09-05_at_8.57.00_AM

This is not a problem I ever encounter in Terminal.app. I initially switched back to Terminal.app after seeing these problems a while ago, but I really want to fix this and make iTerm2 my permanent home now that iTerm2 has the awesome shell integration capabilities.