2

20 years ago, whatever vi I was using used to leave the file contents on the terminal after you quit. This meant you could exit and then copy and paste some of the content you'd just created. With small files, the entire content would still be in the terminal after quitting.

Here I'm using vim 8.1, but happy to use another vi if necessary. When I quit, it resets the terminal (not sure of technical term for exactly what it's doing), so that the shell session resumes where it left off. Is there a configuration option to get the behaviour I described above, instead?

1 Answer 1

4

Add

set t_ti= t_te=

to your .vimrc file, as described in :help rs.


Background

Modern terminal emulators feature an alternate screen buffer. The alternate screen is where Vim runs. When Vim is terminated, the alternate screen is cleared. You can verify that the behavior you want is already present in virtual consoles (TTYs), because they do not have an alternate screen.


Bonus: Disabling Xterm's alternate screen for all programs

Add

XTerm*titeInhibit: true

to your .Xresources file, issue xrdb .Xresources, launch a new Xterm and verify that the output of vim, man, less, etc. is retained when the program is terminated.

3
  • 2
    You can also lie to Vim about the capabilities of the current terminal with e.g. vim -T vt100.
    – Kusalananda
    Nov 23, 2020 at 12:07
  • @Kusalananda Nice, I didn't know that trick. Although it does have implications in colorschemes, at an eyeblink.
    – Quasímodo
    Nov 23, 2020 at 12:10
  • works great. Thanks. Useful background info, too.
    – projix
    Nov 23, 2020 at 20:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .