ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20240812]man vim退出清屏问题.txt

[20240812]man vim退出清屏问题.txt

原创 Linux操作系统 作者:lfree 时间:2024-08-16 21:07:52 0 删除 编辑

[20240812]man vim退出清屏问题.txt

--//以前遇到的问题:
--// https://blog.itpub.net/267265/viewspace-1692405/ --> [20150609]tmux下使用vimless退出清屏问题
--// https://blog.itpub.net/267265/viewspace-1676472/ --> [20150529]man tmux less.txt

--//在tmux下设置:
set-window-option -g alternate-screen off

--//另外一个在没有启动tmux的情况下,也就是登陆终端的情况下:
--//man 的问题通过设置在/etc/man.config文件设置:
export PAGER='/usr/bin/less -isX'

--//不过我这次使用centos 7.3,,没有这个文件,发现存在一个/etc/man_db.conf.
--//取消以下行注解,修改为如下:
# grep -i pager  /etc/man_db.conf
DEFINE  pager   less -isX

--//而使用vim时也遇到类似的情况,不知道如何解决,上网查询发现如下链接:
https://vi.stackexchange.com/questions/432/prevent-vim-from-clearing-the-terminal-after-exit

By default VIM, when terminating, sends the string configured with the option t_te to the hosting terminal to tell it to
clear the screen. To avoid it just :set t_te= to send nothing to the terminal and avoid screen clearing. See :help term
form more information about terminal capabilities.

As you are using an xterm you could use its main and alternate screen buffers for screen swapping, as in this section
from my .vimrc

if &term == "linux"
    set t_ti=^[[?1049h
    set t_te=^[[?1049l
endif                                                       

Note: ^[ is not literal text, it is the escape character, use Ctrl+v followed by Esc to insert it.

These vim commands add the relevant commands which can be missing from the linux terminfo entry. More info at

:help xterm-screens

--//按照上面介绍设置t_te问题可以解决,先查看设置:
--//bash shell下查询:
$ echo $TERM
xterm

:set t_te?t_ti?
  t_te=^[[?1049l
  t_ti=^[[?1049h

--//tmux下查询:
$ echo $TERM
screen

:set t_te?t_ti?
  t_te=^[[?1049l
  t_ti=^[[?1049h
--//这个正常退出,没有问题

--//测试看看设置set t_te=是否可以,我先测试设置看看TERM=linux的情况:
export TERM=linux
:set t_te?t_ti?
  t_te=
  t_ti=

--//这个正常退出,没有问题,说明设置null应该可以。
--//修改/etc/vimrc 加入如下内容:
set t_ti=
set t_te=

--//测试在几种模式下都能正常工作,没有问题.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3025260/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969784