Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I'm not in a screen session, then when exiting Vim I get a bash prompt below the remnants of the VIM window. A side effect of this is that my scrollback buffer is clobbered, especially if I have paged through a long file in VIM. The problem only occurs if I'm not in screen, inside a screen window VIM exits to show the bash prompt and the previous lines just as before.

I tried adding sett_ti=t_te= to my .vimrc to fix the problem, but the only effect that it has was to break VIM such that the problem occurs inside screen as well as outside. Thus, I removed the line.

For good measure I do have altscreen on in .screenrc.

This is on Ubuntu Server 12.04.1 LTS, with Bash 4.2.24, Screen 4.00, and VIM 7.3 (not vim-tiny), accessed over SSH in Cygwin version NT-6.1-WOW64 on a Windows 7 laptop.


EDIT: Note that in the same Cygwin install I can SSH into a different server (CentOS) and there VIM does not clobber the scrollback buffer. Therefore, I do not suspect a Cygwin issue. The CentOS machine does not have screen installed, and I did not have to add set t_ti= t_te= to .vimrc.

share|improve this question
I think resetting t_ti and t_te are going to do the opposite of what you want. – Heptite Nov 21 '12 at 18:59
@Heptite: Really? How should I set them, then? From all that I've been able to google, that is the canonical solution. – dotancohen Nov 21 '12 at 20:55
I could be wrong, but I do know that usually you shouldn't need to set them at all. – Heptite Nov 21 '12 at 23:45
I have confirmed that setting these two options to empty values prevents Vim from switching to the "alternate screen" but in either case my srollback is not being clobbered. Your problem probably lies elsewhere. – Heptite Nov 21 '12 at 23:49
What does the output of "vim --version" show on the server where you're having issues? Does it say "Tiny version" on the fourth or fifth line of output? – Heptite Nov 22 '12 at 0:05
up vote 1 down vote accepted

You shouldn't unset t_ti and t_te, or only when necessary. From vim help:

For normal editing the terminal will be put into "raw" mode. The strings defined with 't_ti' and 't_ks' will be sent to the terminal. Normally this puts the terminal in a state where the termcap codes are valid and activates the cursor and function keys. When Vim exits the terminal will be put back into the mode it was before Vim started. The strings defined with 't_te' and 't_ke' will be sent to the terminal.

I believe your problem is just that: - you unset those (please just delete the lines setting those to and/or - vim doesn't recognise (or know the termcaps used for) the terminal you appear to be using

I'd recommand:

  • delete the "set t_ti= t_te=" part of your vimrc
  • then try different terminals: ex, to test vim using "xterm" as TERM, you can type (from your bash prompt):

TERM=xterm vim

(on the same line, as shown, and with the assignement located before the command)

When you hit a combination that both displays correctly in vim, and that vim knows about (and therefore can set the terminal sequence correctly), it should work. Unless you override the terminal sequences in the vim ressource files, or if there is another option forcing it to clear the terminal on exit.

Explanation for the above : in bash (and sh, and others) setting a variable just before a command will make this command have this variable set to that value, and won't affect the variable's value after the command exits. ex:

bash-2.05b$ echo $TERM
bash-2.05b$ TERM=vt100 ls -F
this/ this.tar
bash-2.05b$ echo $TERM

(TERM=vt100 only during the call of ls) (nice to try different TERM values)

share|improve this answer
thanks, oliver salzburg, for your reformating (I forgot to check that the example was preformated correctly) – Olivier Dulac Nov 26 '12 at 16:47
Thanks Oliver, that gave me all the info that I needed to know to google my way out of this mess. – dotancohen Nov 27 '12 at 22:09
I'm glad. Enjoy! And maybe edit your post (or comment here?) to contribute to others what you did, if it's "portable" enough (I don't have your equipment, but many do, and may be saved the trouble of finding what in the end worked out.) – Olivier Dulac Nov 28 '12 at 10:05
Actually, I still don't have it all working, but I have a few 'promising' pages open in Firefox for me to sort through later this week. I will update the post with the solution when I get it sorted out. Thanks! – dotancohen Nov 28 '12 at 10:06

You must log in to answer this question.

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