在 tmux 会话中打开的 vim 进程中移动光标时,为什么会时不时地留下一串幽灵字符

编程入门 行业动态 更新时间:2024-10-28 17:23:43
本文介绍了在 tmux 会话中打开的 vim 进程中移动光标时,为什么会时不时地留下一串幽灵字符 - ^[OB, ^[OA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

如果我向上翻页和向下翻页,这些就会消失.为什么会发生这种情况,我该如何纠正?

These disappear if I do a page-up and page-down. Why does this happen and how do I rectify it?

http://i.stack.imgur/DnMYl.png

我最近在摆弄我的 vimrc.这可能是原因吗?

I recently fiddled around with my vimrc. Could that be the cause?

更新:我想出了原因.我添加了自动更新我的 vim 状态行中的 cwd 名称和当前 git 分支的函数.这导致 vim 滞后,每次它在上/下/左/右键点击时滞后,它都会打印出鬼字符 ^[OA 等.因为我在 tmux 中使用 vim,所以事情可能变得复杂了,但我也看到了 tmux 之外的幽灵字符.所以,可能不是.我已经在我的 .vimrc 中关闭了这两个功能,我的 vim 状态行现在没有以前那么棒了:(希望有出路.

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.

推荐答案

^[OB^[OA 是你的终端如何表示.

^[OB and ^[OA are how your terminal represent <down> and <up>.

我已经看到这些(以及他们的朋友 ^[OC^[OD)出现在命令行"或全方位完成菜单中以及在使用tmux 中 vim 中的几个插件.

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:

map ^[OA <up>
map ^[OB <down>
map ^[OC <right>
map ^[OD <left>

如果你不知道,你一定不要把^[输入为两个字符,你必须输入<C-v><Esc>.

In case you don't know, you must not type ^[ as two characters, you must do <C-v><Esc>.

也就是说,在 --INSERT-- 模式下同时按下 Control 键和 V 键,然后点击 退出键.这样做将输入正确的单个字符,看起来像^[.

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 ^[.

这篇关于在 tmux 会话中打开的 vim 进程中移动光标时,为什么会时不时地留下一串幽灵字符 - ^[OB, ^[OA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 05:10:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1390258.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:光标   幽灵   中移动   字符   进程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!