Очистка экрана после выхода из Vim в FreeBSD
Добавлено: 2008-08-30 15:32:34
после выхода из вим на экране остается содержимое файла который редактировался.
хочу, чтобы после выхода из вим восстанавливалось то что было до запуска вим и отрытия файла.
есть несколько путей решить эту проблему, вот выдержка из документации 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 /usr/5bin/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=
====================================================================
Пробовал раскоментарить FEAT_XTERM_SAVE в feature.h, чтобы включить фичу +xterm_save
но тогда вим не хочет собираться, ругается на ошибку синтаксиса.
В /etc/termcap тоже непонятно где прописывать, для xterm вроде там уже прописано..
непонятно, почему нужно редактировать termcap если собраный вим говорит что собрался с поддержкой +terminfo,
а я его почему-то не нашел в системе. В общем запутался совсем. подскажите пжл кто сталкивался с подобным.
Система: FreeBSD 6.1-RELEASE, локаль koi-8r, вим 7.2 sources
хочу, чтобы после выхода из вим восстанавливалось то что было до запуска вим и отрытия файла.
есть несколько путей решить эту проблему, вот выдержка из документации 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 /usr/5bin/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=
====================================================================
Пробовал раскоментарить FEAT_XTERM_SAVE в feature.h, чтобы включить фичу +xterm_save
но тогда вим не хочет собираться, ругается на ошибку синтаксиса.
В /etc/termcap тоже непонятно где прописывать, для xterm вроде там уже прописано..
непонятно, почему нужно редактировать termcap если собраный вим говорит что собрался с поддержкой +terminfo,
а я его почему-то не нашел в системе. В общем запутался совсем. подскажите пжл кто сталкивался с подобным.
Система: FreeBSD 6.1-RELEASE, локаль koi-8r, вим 7.2 sources