Vim/GVim键映射 [英] Vim/GVim key mappings

查看:89
本文介绍了Vim/GVim键映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经专门使用Vim了几个星期,并且有几件事使我对迄今为止的经验感到非常兴奋.首先,我在将一些键序列映射到命令时遇到了麻烦.

我想将 Ctrl + Shift + Z 映射到:redo<CR><C-R>,但是显然是 Vim无法 认识到已转换和已转换之间的差异不变的控制键序列:

Ctrl-b和Ctrl-B是同义词,均表示0x02.这不能是 更改后,它返回到ASCII,可追溯到7孔纸带 (不包括奇偶校验).

这对我来说似乎很愚蠢.自从7孔纸带以来,我们已经走了很长一段路,根据我的经验,许多程序认识到<C-S-Z><C-Z>之间的区别.的确,MacVim甚至意识到了差异!但是在GVim或GNOME终端中没有喜悦.有没有解决的办法?也许是插件,甚至是一些编译时选项?

我遇到麻烦的另一个组合键是 Ctrl + (Ctrl +逗号).我不确定我的.vimrc中是否配置了错误,或者Vim确实存在问题,但是在映射它后我无法让<C-,>响应(例如:map <C-,> :TComment<CR>). FWIW,我将我的领导者密钥重新映射到;.我做错了吗?还是有其他原因导致Vim无法识别<C-,>组合键?

我花了太多时间在关键字映射上进行搜索和摆弄,而且我濒临宣布Vim不如我所相信的那样灵活……我什至无法理解它配置了我惯用的键映射,我不愿意重新/取消学习其中的一些键映射,因为它们在我每天使用的其他程序中都可以使用.

解决方案

您发布的链接似乎已经回答了有关<C-b><C-B>的问题.根据常见问题解答,您似乎对<同样也是c5>,因为此组合键不在Vim可以检测到的Ctrl-可打印键和弦列表中(可能是因为它甚至不是可打印的ASCII和弦?).

诸如<C-S-w>的键组合非常类似于 Vim,在于它们破坏了模式编辑器的效率.当然,有时候需要<CTRL>转义的组合(例如,在插入模式映射中,例如<C-x>-<C-o>用于全功能完成),但是对于诸如undo和redo之类的操作则不是这种情况.

很抱歉,这个答复不能使您满意,但是从长远来看,以Vim的方式进行操作"将有很多好处,而不是试图让Vim随心所欲.

I've been using Vim exclusively for a few weeks now, and a few things are keeping me from being very excited about my experience so far. For one, I am having trouble mapping a few key sequences to commands.

I'd like to map Ctrl+Shift+Z to :redo<CR> or alternately <C-R>, but apparently Vim is not able to recognize the difference between shifted and un-shifted control-key sequences:

Ctrl-b and Ctrl-B are synonymous, they both mean 0x02. This cannot be changed, it goes back to ASCII, which dates back to 7-hole paper tape (not counting parity).

This just seems silly to me. We've come a long way since 7-hole paper tape, and in my experience MANY programs recognize the difference between <C-S-Z> and <C-Z>. Indeed, MacVim even recognizes the difference! But no joy in GVim or in the GNOME Terminal. Is there a way around this? Maybe a plugin or even some compile-time option?

The other key combo that I'm having trouble with is Ctrl+, (control+comma). I'm not sure if I've got something configured wrong in my .vimrc, or if it's a real issue with Vim, but I cannot get <C-,> to respond after mapping it (for example: map <C-,> :TComment<CR>). FWIW, I have my leader key remapped to ;. Am I doing it wrong? Or is there some other reason why Vim won't recognize the <C-,> key combo?

I've spent way too much time googling and fiddling with key mappings, and I'm on the verge of declaring that Vim is not as flexible as I've been led to believe... I can't even get it configured with the key mappings I'm used to, some of which I am reluctant to re/unlearn since they work in other programs that I use daily.

解决方案

It looks like the link you posted already answers your question regarding <C-b> vs. <C-B>. According to the FAQ it looks like you're out of luck with <C-,> as well, since this key combination is not in the list of Ctrl-printable-key chords that Vim can detect (possibly because it's not even a printable ASCII chord?).

Key combinations such as <C-S-w> are very un-Vim-like in that they undermine the efficiency of a modal editor. Of course there are times when <CTRL>-escaped combinations are necessary (for example in insert-mode mappings such as <C-x>-<C-o> for omnicompletion), but that's not the case for operations such as undo and redo.

I'm sorry that this reply won't satisfy you, but in the long run there is much to be gained from "doing it the Vim way", rather than trying to bend Vim to your will.

这篇关于Vim/GVim键映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆