GNOME Bugzilla – Bug 746767
Content does not scroll after running vim
Last modified: 2015-03-25 20:23:39 UTC
I noticed vte (and all the terminals I tried based on it) sometime stops to scroll. I usually use <SHIFT><PgUp> and when the scroll stops working I get ~2 on the command line instead. All the other scrolling shortcuts are affected as well. After *ages* I tracked down the problem to VIM. If I disable the screen restoring with `set t_ti= t_te=` (as suggested by the official VIM help [1]) I consistently get this behavior. xterm is not affected. [1] http://vimdoc.sourceforge.net/htmldoc/options.html#'restorescreen'
The key for being able to restore the screen is that there are two screens: - The default "normal" screen which has a scrollback buffer, "te" (e.g.: echo -ne '\e[?1049l') switches to this mode; - The "alternate" screen (typically used by apps such as vim) which doesn't have a scrollback buffer; "ti" (echo -ne '\e[?1049h') switches to this mode. There are two differences from xterm that I'm aware of: - In xterm, when the alternate screen is present, you can still drag the scrollbar with the mouse (though Shift+PageUp doesn't scroll). In vte (and all other terminals I'm aware of) there's absolutely no way to scroll back and see the normal screen's scrollback buffer as long as the alternate screen is active. - On xterm's alternate screen, Shift+PageUp or Shift+PageDn sends Up or Down arrows multiple times (half of the screen's height many times) (but this behavior is subject to some configuration item I guess), whereas vte sends the PageUp or PageDn key's sequence with the Shift modifier properly encoded so that apps can benefit from this (which might easily end up displayed as "~2"). Does this explain the story to you? Or is there a sequence of events that leave you stuck on alternate screen in vte but take you back to the normal screen in xterm?
(In reply to Egmont Koblinger from comment #1) > Does this explain the story to you? Or is there a sequence of events that > leave you stuck on alternate screen in vte but take you back to the normal > screen in xterm? Yes, that explains it. I tried switching to normal mode after the issue and the scrolling came back together with the old screen content. If I understood well VIM is already in alternate mode when it parses .vimrc (where `set t_ti= t_te=` was found) so when I exit the terminal is left in that mode. Curiously enough I can use VIM in normal mode with `vim --cmd "set t_ti="`. I'll report a bug against VIM.