I'm using the stock terminal with zsh and vim. After I exit vim, the file contents remains in the terminal. Ideally, only the previous history would be in the terminal when I exit vim (such as the behavior I've seen with linux/bash).

How can I accomplish that?


I'm running os x Yosemite 10.10.1

I tried glenn jackman's suggestion below, but still no dice.

Additional information:

echo $TERM produces ansi

I also tried in bash with the same results.

I also tried removing .vimrc completely with the same results.

  • Weird. On my Lion system, running vim under zsh nets the usual exit, i.e., the file contents are not visible. Jan 25, 2015 at 3:07
  • Try setting TERM=xterm in the shell before opening vim. Jan 27, 2015 at 0:30

2 Answers 2


I figured it out:

Similar to glenn jackman's solution, I added

if &term =~ "ansi"
    let &t_ti = "\<Esc>[?47h"
    let &t_te = "\<Esc>[?47l"

to my .vimrc file (notice the ansi instead of xterm).

This fixed the issue.


Try adding:

if &term =~ "xterm"
    let &t_ti = "\<Esc>[?47h"
    let &t_te = "\<Esc>[?47l"

to your ~/.vimrc

Ref: https://forums.vandyke.com/showthread.php?t=3431


You must log in to answer this question.

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