Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping view of edited file after exiting vim

Tags:

vim

When I quit vim, the display reverts to whatever I was seeing before I entered. On non-vim vi, you keep the vi screen intact except for the bottom line.

Is there an option in vim that allows that latter behaviour?

like image 438
rojomoke Avatar asked Oct 19 '25 23:10

rojomoke


1 Answers

Vim uses a terminal feature called the alternate screen to write its UI there, and restore the original shell contents (where Vim was launched from) on exit. This is controlled by two ANSI escape sequences (see how does vi restore terminal content after quitting it).

You can disable that from within Vim by clearing the corresponding terminal settings. Put the following into your ~/.vimrc:

set t_ti= t_te=

Alternatively, you could also disable this capability in the terminal; at least the multiplexers screen and tmux allow this. See Prevent Applications Like Vim and Less Clearing Screen on Exit for details. For example, for tmux, add set-window-option -g alternate-screen off to your .tmux.conf; for screen, add alterscreen off to your .screenrc.

like image 99
Ingo Karkat Avatar answered Oct 21 '25 12:10

Ingo Karkat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!