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

Currently, when I run vi in ​​the terminal window on the screen, the vi program captures the entire screen and closes any of the output history that was there, and then remains there after exiting. Thus, when scrolling back through my terminal output at a later time, the output in window vi is masked.

I am currently working on this with the following alias in my bashrc ...

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

So far it has worked perfectly, but it amazes me as a kind of kludgy, and I am afraid that I am in an unforeseen situation, when at some point I fail. I was wondering if there is a command option for vi or screen or some other simpler and more efficient way to achieve the same.

Thanks.

+4
source share
2 answers

If you are using the GNU screen, the following line in your .screenrc should solve the problem:

 altscreen on 

This ensures that the old content will be restored after exiting Vi, and it will no longer clutter your scroll history.

+6
source

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

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

Note. Some terminals, such as urxvt, can fix this globally for all ncurses programs with the following settings: urxvt*secondaryScreen: false

+2
source

All Articles