歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Vim退出後恢復終端內容

Vim退出後恢復終端內容

日期:2017/2/28 14:53:49   编辑:Linux教程

有些終端在vim退出後可以恢復到打開vim前終端的狀態,類似這樣:

$ 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上就不需要)

用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

這樣應該就能解決問題了。

另外,有些朋友喜歡用screen進行多屏管理,如果也想要這種效果,需要在.screenrc配置文件中加入一行 altscreen on,如果是root用戶,可以編輯/etc/screenrc,找到altscreen,取消前面的注釋即可。

Copyright © Linux教程網 All Rights Reserved