你能让vi“前进”吗? 打开时的屏幕?

发布于 2024-07-14 09:27:41 字数 266 浏览 5 评论 0原文

我经常在 vi 中工作,暂停 vi,在 cli 上运行一些东西,然后返回 vi 来处理结果。 例如,修复运行 cli 命令时出现的错误。

但是,当我 fg vi 时,vi 会“擦除”当前终端缓冲区,并且我在回滚缓冲区中看不到终端输出的“最后一屏”。

vi(或屏幕,我使用屏幕)中是否有一些设置可以帮助我?

我用谷歌搜索了很长时间没有答案。 我还意识到还有其他工作流程可以解决此问题,但它们并不完美(从 vi 内部运行意味着没有 shell 完成等)。

I often work in vi, suspend vi, run something on the cli, and then fg back into vi to work on the results. For instance, fixing errors that showed up when I ran the cli command.

However, when I fg vi, vi "wipes" the current terminal buffer and I can't see the "last screenful" of terminal output in the scrollback buffer.

Is there some setting in vi (or screen, I use screen) which would help me here?

I have searched google for a long time with no answers. I also realize that there are other workflows that solve this problem, but they aren't perfect (run from inside vi means no shell completion, etc).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

廻憶裏菂餘溫 2024-07-21 09:27:41

如果您使用的是 screen,那么在一个窗口中进行编辑、在另一个窗口中进行编译肯定是有意义的,然后只需使用 ^A[n] 在终端输出和代码屏幕之间切换的序列?

If you're using screen, then surely it would make sense to do your editing in one window, and your compiles in the other, and then just use the ^A[n] sequences to flip between your terminal output and code screens?

蘸点软妹酱 2024-07-21 09:27:41

我不能 100% 确定这是否对您有帮助,但 vim 会尝试恢复启动时发现的屏幕。 我喜欢这种行为,并花了相当多的时间来“修复”一台无法正常工作的机器上的 vim 安装。

我必须设置 t_tit_te 变量。 我的直觉是你应该取消设置 t_te。

I'm not 100% sure whether this will help you or not, but vim tries to restore the screen it found when it was started. I like that behavior and spent quite a bit of time to "repair" a vim installation on a machine where this didn't work.

I had to set the t_ti and t_te variables. My hunch is that you should unset t_te.

烟雨凡馨 2024-07-21 09:27:41

此评论中回答您的问题答案:它似乎实际上是t_ti变量。 在 ~/.vimrc 中添加一行内容:

set t_ti=""

您可以通过在 : 提示符下输入该命令,首先在 vim 中尝试它。

In answer to your question in your comment on this answer: it seems to actually be the t_ti variable. In your ~/.vimrc add a line that says:

set t_ti=""

You can try it out first from within vim by entering that command at the : prompt.

混浊又暗下来 2024-07-21 09:27:41

我不知道这是否有帮助,但是:我现在使用 mac,但我以前在大学使用 NetBSD 和 Linux。 lessmanvi 等程序退出时会清除屏幕,这一点一直困扰着我。 我可以使用 -X 选项在 less 中将其关闭,但这对于其他选项来说不是(字面意思)。

我在 xterm 中找到了一个配置设置,它解决了我的问题。 恐怕我不记得这个选项了; 它可以通过其中一个菜单获得,我认为可以通过 -xrw 命令行选项。

显然,只有使用 xterm 时这才有用。

I don't know if this will help but: I use a mac these days, but I used to use NetBSD and Linux at uni. It always bugged me that programs like less, man, vi, etc. would clear the screen when they exited. I could switch it off in less with the -X option, but that wasn't an option (literally) with the others.

I found a config setting in xterm that solved the problem for me. I'm afraid I don't remember the option; it was available through one of the menus and I think through the -xrw commandline option.

Obviously this can only be helpful if you use xterm.

自由如风 2024-07-21 09:27:41

将终端类型更改为 ansi 可能会起作用:

:set term=ansi

但我确信会有一些负面影响。

Changing your terminal type to ansi could work:

:set term=ansi

But I'm sure there are some negative side effects.

夜司空 2024-07-21 09:27:41

这不是一个解决方案,而是一个很好的解决方法,我刚刚开始使用。 为 vi 创建以下包装器脚本(我将其放在 ~/bin/vim-wrapper 中),并可能使用类似以下内容的别名:

alias vi='~/bin/vim-wrapper'

vim-wrapper 的内容(请参阅 此答案了解详细信息):

#!/bin/bash
LINES=$(tput lines)
for i in `seq 1 $LINES`; do
    echo $i
done
vim $@

这将完全解决屏幕消失问题。 不幸的是,它没有解决在 vim 中编辑长文件时必须向上滚动很多的问题。 但如果你在类似 xterm 的系统中设置了足够大的缓冲区(我使用 gnome 终端 2.22.1),那就没问题了。

This is not a solution, but a nice workaround, that I've just started using. Create the following wrapper script for vi (I placed it in my ~/bin/vim-wrapper) and possibly alias it with something like:

alias vi='~/bin/vim-wrapper'

Content of vim-wrapper (see this answer for details):

#!/bin/bash
LINES=$(tput lines)
for i in `seq 1 $LINES`; do
    echo $i
done
vim $@

This will solve completely the screen wiped out issue. Unfortunately, it does not solve the have to scroll up quite a lot when you edit a long file in vim. But if you set a large enough buffer in your xterm-like (I use gnome terminal 2.22.1) you'd be ok.

老街孤人 2024-07-21 09:27:41

滚动屏幕 Ctrl+ECtrl+Y 也可能达到此目的。

It is possible that scrolling the screen Ctrl+E or Ctrl+Y might do the trick as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文