vim退出后恢复终端内容
vim退出后恢复终端内容
vim退出后恢复终端内容
有些终端在vim退出后可以恢复到打开vim前终端的状态,类似这样:
www.2cto.com
$ vim /etc/sysconfig/
####这里表示打开vim#####
sdskk,一些文件内容
:q
$ vim /etc/sysconfig/ ##终端恢复到先前状态
但是有些不行,解决这个问题需要以下两步:
1、设置TERM环境变量为xterm 或者 xterm-color,可以在.bashrc文件中添加:export TERM=xterm-color
2、设置vim的t_ti和t_te变量的值(可选,例如在centos上就不需要)
www.2cto.com
用vim打开一个文件,normal模式下输入:set t_ti 或者 :set t_te,若值类似:"^[[?1049h" and "^[[?1049l",那么你需要在.vimrc中加入下面几行:
if &term =~ "xterm"
" SecureCRT versions prior to 6.1.x do not support 4-digit DECSET
" let &t_ti = "\<Esc>[?1049h"
" let &t_te = "\<Esc>[?1049l"
" Use 2-digit DECSET instead
let &t_ti = "\<Esc>[?47h"
let &t_te = "\<Esc>[?47l"
endif
转自:http://forums.vandyke.com/showthread.php?t=3431
这样应该就能解决问题了。 www.2cto.com
另外,有些朋友喜欢用screen进行多屏管理,如果也想要这种效果,需要在.screenrc配置文件中加入一行 altscreen on,如果是root用户,可以编辑/etc/screenrc,找到altscreen,取消前面的注释即可。
评论暂时关闭