Vim在Mingw上表现怪异 [英] Vim behaving weirdly on Mingw
问题描述
我在MinGW 4.6.2上的Vim表现异常,例如,在插入模式下按Backspace键会删除字符,但是在删除的字符消失之前,我必须使用箭头键移动光标,这也使我退出了插入模式
My Vim on MinGW 4.6.2 is behaving weirdly, for example, pressing Backspace in insert mode deletes characters, but I have to move the cursor with arrow keys before the deleted characters disappear, and it also takes me out of insert mode.
另一个示例,按Del键删除字符有时会生成奇怪的字符,例如将小写字符更改为大写字母,或者破坏我键入的下一个字符,例如,按'S'会使我最初获得'$'.
Another example, pressing Del to delete characters sometimes generates weird characters like changing lowercase characters to uppercase, or corrupts the next character that I key in, for example pressing 'S' gives me '$' initally.
我使用Vim错了吗?我不太了解Vim,所以不确定这是否是默认行为,但是据我了解,典型的Vim行为就像Git Bash中的Vim,其中Backspace和Del的工作方式与NotePad中的一样.
Am I using Vim wrong or something? I'm not too unfamiliar with Vim so I'm not sure if this is default behaviour, but the typical Vim behaviour as I understand is like the Vim in Git Bash, where Backspace and Del work like they do in NotePad.
推荐答案
问题是,退格经常是^H
,而删除经常是^?
-一些白痴终端将两者互换或具有相同的字符.当某些终端确实是 错误时,按键将生成ESC~<something>
,而ESC
会将vim
置于命令模式,然后~
将交换字符的大小写,依此类推.
The thing is, backspace is often ^H
and delete is often ^?
-- and some idiot terminals swap the two or have both provide the same character. When some terminals are really wrong, a keypress will generate ESC~<something>
and the ESC
will put vim
into command mode, then the ~
will swap the case of characters, and so on.
您还需要处理终端功能的terminfo
或termcap
数据库-如果您的TERM
环境变量与运行的终端不完全匹配,则会选择错误的功能,应用程序将生成错误的转义序列以正确控制终端.
You've also got the terminfo
or termcap
databases of terminal capabilities to contend with -- if your TERM
environment variable does not match the running terminal exactly, the wrong capabilities will be selected and the application will generate the wrong escape sequences to properly control the terminal.
当然,在Windows上运行会进一步使一切复杂化,因为终端不是平台本身所特有的-CMD.EXE
做自己的事情,MSYS
做另一件事,并且vim
可能是标准的
Of course, running on Windows further complicates everything because terminals aren't very native to the platform -- CMD.EXE
does its own thing, MSYS
does another, and vim
is probably expected bog-standard CMD.EXE
just because it is quite common.
所有这些都是为什么我建议使用gvim
的原因;它会启动一个GUI窗口,其行为几乎与文本模式vim
完全相同,但是它的行为更具可预测性,您可以在gvim
内完全配置它-修复vim
的行为实际上可能意味着更改MSYS
配置,这可能会破坏 other 程序.我不喜欢gvim
启动新上下文"的方式,而不仅仅是在已经使用的环境中进行编辑,但是gvim
在Windows下感觉不太尴尬.
All these are reasons why I'd recommend using gvim
; it starts a GUI window that behaves almost exactly like the text-mode vim
, but it is much more predictable in its behavior and you can configure it entirely within gvim
-- fixing vim
's behavior might actually mean changing the MSYS
configuration, which may break other programs. I dislike the way gvim
starts a "new context" rather than just editing in the environment I'm already using but gvim
feels way less awkward under Windows.
这篇关于Vim在Mingw上表现怪异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!