10

If I do:

$ less file

And press q to exit less, I stil see the same text as I had on the screen when less was still running.

However, if I do

$ vim file

And :q, my terminal is blanked...

Screenshots of my terminal after quiting less and vim:

enter image description here enter image description here

Can I somehow prevent this? This is only on my Linux system. My FreeBSD system actually works as expected (using the same software/settings all around, TERM is xterm-color for both, vim -u NONE doesn't make a difference).

Example of what I would like to have:

enter image description here

13

By default VIM, when terminating, sends the string configured with the option t_te to the hosting terminal to tell it to clear the screen. To avoid it just :set t_te= to send nothing to the terminal and avoid screen clearing. See :help term form more information about terminal capabilities.

2

As you are using an xterm you could use its main and alternate screen buffers for screen swapping, as in this section from my .vimrc

if &term == "linux"
    set t_ti=^[[?1049h
    set t_te=^[[?1049l
endif                                                       

Note: ^[ is not literal text, it is the escape character, use Ctrl+v followed by Esc to insert it.

These vim commands add the relevant commands which can be missing from the linux terminfo entry. More info at

:help xterm-screens
  • Hm, still doesn't seem to do anything? It works as if I use set t_te=, but it's supposed to do more, I think? – Martin Tournoij Feb 5 '15 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.