当在 tmux 会话中打开的 vim 进程上移动光标时,为什么它时不时地会留下幽灵字符的痕迹 - ^[OB,^[OA?
如果我向上翻页和向下翻页,这些就会消失。为什么会发生这种情况以及如何纠正?
https://i.sstatic.net/DnMYl.png
我最近摆弄了我的 vimrc。这可能是原因吗?
更新: 我找出原因了。我添加了自动更新 vim 状态行中的 cwd 名称和当前 git 分支的功能。这导致 vim 滞后,每次上/下/左/右键点击时出现滞后,它都会打印出幽灵字符 ^[OA 等。 事情可能变得复杂,因为我在 tmux 中使用 vim,但我也在 tmux 之外看到了幽灵字符。所以,可能不会。 我已经关闭了 .vimrc 中的这两个功能,并且我的 vim 状态栏目前不如以前那么棒了:( 但愿有一条出路。
These disappear if I do a page-up and page-down. Why does this happen and how do I rectify it?
https://i.sstatic.net/DnMYl.png
I recently fiddled around with my vimrc. Could that be the cause?
UPDATE:
I figured out the cause. I had added to functions that automatically updated the cwd name and the current git branch in my vim statusline. This caused vim to be laggy and everytime it lagged on a up/down/left/right key hit, it printed out the ghost characters ^[OA, etc.
It's possible that stuff got complicated because I was using vim in tmux, but I saw the ghost characters outside tmux also. So, probably not.
I've turned off those two functions in my .vimrc and my vim statusline is presently less awesome than it used to be :(
Wish there's a way out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
^[OB
和^[OA
是终端表示
和
的方式。我已经看到这些(以及它们的朋友
^[OC
和^[OD
)出现在“命令行”或全能完成菜单中以及在使用几个tmux 中 vim 中的插件。我的解决方案是将它们映射到方向键:
如果您不知道,则不得输入
^[
作为两个字符,您必须执行。
。也就是说,在
--INSERT--
模式下同时按 Control 键和 V 键,然后按 Escape键。这样做将输入正确的单个字符,类似于^[
。^[OB
and^[OA
are how your terminal represent<down>
and<up>
.I've seen these (and their friends
^[OC
and^[OD
) appear in the "command line" or omni-completion menus and during usage of a couple of plugins in vim in tmux.My solution was to map them to the directional keys:
In case you don't know, you must not type
^[
as two characters, you must do<C-v><Esc>
.That is, while in
--INSERT--
mode press the Control key and the V key together then hit the Escape key. Doing so will input the correct single character that looks like^[
.Vim Wiki 文章 详细讨论了这个问题。似乎有多种原因,我个人在tmux下运行vim时遇到了这个问题。
那里的一个解决方案对我有用,并且看起来比映射键更简单,它是以下配置:
set term=cons25
This issue is discussed at length on the Vim Wiki article. There seem to be multiple causes, I personally encountered this issue when running vim under tmux.
A solution from there that worked for me and seems less hacky than mapping the keys was the following config:
set term=cons25
如果不知道你的 vimrc 中有什么,很难说,但是你可以通过启动它而不运行它来确认它是否存在,并使用以下命令查看它是否仍然发生...
vim -u NONE
Hard to say without knowing what's in your vimrc, but you can confirm whether it's something in there by starting it up without running it and seeing if it still happens using the following...
vim -u NONE
你碰巧正在使用 zsh 吗?我在使用 vim + zsh/oh-my-zsh 时遇到了这个问题。回到 vanilla bash 解决了我在 vim 中遇到的这个问题(以及其他问题)。
Do you happen to be using zsh? I had this issue with vim + zsh/oh-my-zsh. Moving back to vanilla bash solved this issue (amongst others) that I was having with vim.