Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop VI from overlapping and hiding the last page of command line output?

Currently, when I start vi in a terminal window within screen, the vi program takes up the full screen and covers up any of the output history that was there, and then remains there upon exiting. Thus, when scrolling back through my terminal output at a later time, the output under the vi window is masked.

I'm currently working around this with the following alias in my bashrc...

alias vi='for i in $( seq 1 $LINES ); do echo ; done ; vi'

This has worked just fine so far, but it strikes me as kind of kludgy and I fear I'm going to hit an unforeseen situation where it fails me at some point. I was wondering if there's a command option for either vi or screen or some other simpler, more efficient way of achieving the same.

Thanks.

like image 847
Costa Avatar asked Feb 25 '23 04:02

Costa


2 Answers

If you use GNU Screen, the following line in your .screenrc should solve the problem:

altscreen on

This will ensure that the old contents is restored after you exit Vi, and it won't clutter your scrollback history anymore.

like image 151
Adam Byrtek Avatar answered Apr 06 '23 13:04

Adam Byrtek


Try adding set t_ti= t_te= to your .vimrc file.

To fix less which also exhibits this behavior, set export LESS=-X in your .bashrc file.

Note: Some terminals such as urxvt are able to fix this globally for all ncurses program with a settings like this: urxvt*secondaryScreen: false

like image 36
Caleb Avatar answered Apr 06 '23 12:04

Caleb