免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 11015 | 回复: 8

退出vi后,怎样使文本内容不显示在屏幕上 [复制链接]

论坛徽章:
0
发表于 2011-09-30 10:17 |显示全部楼层
如题

经常在不同linux平台,或同一平台的不同版本中使用vi编辑文本文件,有时发现正常退出vi后,有些服务器上文本文件内容显示在终端屏幕上;有些文本文件内容不显示在终端屏幕上。

哪位兄台能否帮忙指导下如何设置,可重现上述两种情况,谢谢!

论坛徽章:
0
发表于 2011-10-01 00:45 |显示全部楼层
一言难尽啊。。。

这个和你用的终端类型,vim源码设置,vim配置文件有关

一般使用VT100,退出vim后不会恢复编辑前的屏幕内容
使用xterm可以设置成恢复打开vim前的屏幕,也可以设置成不恢复

摘一段vim内的说明:



Switching screens in an xterm           xterm-screens xterm-save-screen
  
(From comp.editors, by Juergen Weigert, in reply to a question)

:> Another question is that after exiting vim, the screen is left as it
:> was, i.e. the contents of the file I was viewing (editing) was left on
:> the screen. The output from my previous like "ls" were lost,
:> ie. no longer in the scrolling buffer. I know that there is a way to
:> restore the screen after exiting vim or other vi like editors,
:> I just don't know how. Helps are appreciated. Thanks.
:
:I imagine someone else can answer this.  I assume though that vim and vi do
:the same thing as each other for a given xterm setup.
   
They not necessarily do the same thing, as this may be a termcap vs.
terminfo problem.  You should be aware that there are two databases for
describing attributes of a particular type of terminal: termcap and
terminfo.  This can cause differences when the entries differ AND when of
the programs in question one uses terminfo and the other uses termcap
(also see +terminfo).

In your particular problem, you are looking for the control sequences
^[[?47h and ^[[?47l.  These switch between xterms alternate and main screen
buffer.  As a quick workaround a command sequence like >
        echo -n "^[[?47h"; vim ... ; echo -n "^[[?47l"
may do what you want.  (My notation ^[ means the ESC character, further down
you'll see that the databases use \E instead).

On startup, vim echoes the value of the termcap variable ti (terminfo:
smcup) to the terminal.  When exiting, it echoes te (terminfo: rmcup).  Thus
these two variables are the correct place where the above mentioned control
sequences should go.

Compare your xterm termcap entry (found in /etc/termcap) with your xterm
terminfo entry (retrieved with "infocmp -C xterm").  Both should contain
entries similar to: >

        :te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:

PS: If you find any difference, someone (your sysadmin?) should better check
    the complete termcap and terminfo database for consistency.
  
NOTE 1: If you recompile Vim with FEAT_XTERM_SAVE defined in feature.h, the
builtin xterm will include the mentioned "te" and "ti" entries.

NOTE 2: If you want to disable the screen switching, and you don't want to
change your termcap, you can add these lines to your .vimrc: >
        :set t_ti= t_te=

论坛徽章:
0
发表于 2011-10-02 09:16 |显示全部楼层
不行手工直接输入clear解决

论坛徽章:
0
发表于 2011-10-02 10:28 |显示全部楼层
这个倒真没研究过,但我觉得无所谓啊

论坛徽章:
0
发表于 2011-10-02 14:21 |显示全部楼层
kernel.org 被黑至今仍未恢复,o(∩∩)o...哈哈,各位还是用 FreeBSD 吧

论坛徽章:
0
发表于 2011-10-02 22:38 |显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
发表于 2011-10-02 23:05 |显示全部楼层
回复  rel23a7


    你咋知道是被黑了啊,我还以为真是在Down for maintenance呢,无语
oxangen 发表于 2011-10-02 22:38



    不是一两天了,git 系统被黑

论坛徽章:
0
发表于 2011-10-03 11:03 |显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
发表于 2011-10-08 09:41 |显示全部楼层
回复 2# yanu


    多谢YANU兄的回复,先研究下,呵呵,先谢了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP