当在 gnu 屏幕中使用 vim 或 less 时,退出 vim 或 less 会留下挥之不去的印记
在我的新 Ubuntu 系统上,我启动一个屏幕会话并在 vim 中编辑文件或在 less 中查看它。退出后,屏幕不会自行重绘,而只是向上滚动以在我刚刚在 vim 或更少中查看的所有内容下显示命令行。
我怎样才能改变这个,以便退出 vim 会让我返回到调用 vim 之前的屏幕?
On my new Ubuntu system, I start a screen session and edit a file in vim or view it in less. After I quit, the screen doesn't redraw itself, but simply scrolls up to show a command line under all the stuff I was just viewing in vim or less.
How can I change this so that quitting vim will return me to the screen the way it was before I invoked vim?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
screen 的
altscreen
(备用屏幕)功能默认处于关闭状态。将其添加到您的
.screenrc
中:请参阅:http ://www.gnu.org/software/screen/manual/screen.html#Redisplay
screen's
altscreen
(alternate screen) feature is turned off by default.Add this to your
.screenrc
:See: http://www.gnu.org/software/screen/manual/screen.html#Redisplay
这是由于您的 termcap for screen 不完整造成的。 (这似乎是一个非常常见的问题。)Vim 不知道恢复屏幕的顺序,所以它只是保持原样。
您可以通过将 vim 的 term 选项(或启动 vim 之前的 TERM 环境变量)设置为“屏幕兼容”的终端(例如 xterm)来解决此问题。例如:
或(在vim中):
您可以将vim中的
t_ti
和t_te
选项设置为正确的代码。请参阅 vim 中的:help xterm-screens
了解更多详细信息。This is caused by your termcap for screen being incomplete. (This seems to be a really common problem.) Vim doesn't know the sequence for restoring the screen, so it just leaves it like it was.
You can work around this problem by setting vim's term option (or the TERM environment variable before you start vim) to a terminal that's "screen compatible", like xterm. eg:
or (in vim):
You can set the
t_ti
andt_te
options in vim to the right codes. See:help xterm-screens
in vim for more details.