简体   繁体   English

Vim/GVim 键映射

[英]Vim/GVim key mappings

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.几周以来,我一直在专门使用 Vim,到目前为止,有几件事让我对自己的体验感到非常兴奋。 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 <CR> , but apparentlyVim is not able to recognize the difference between shifted and un-shifted control-key sequences:我想 map Ctrl + Shift + Z:redo<CR>或交替<CR> ,但显然Vim 无法识别移位和未移位的控制键序列之间的区别

Ctrl-b and Ctrl-B are synonymous, they both mean 0x02. Ctrl-b 和 Ctrl-B 是同义词,它们都表示 0x02。 This cannot be changed, it goes back to ASCII, which dates back to 7-hole paper tape (not counting parity).这不能改变,它可以追溯到 ASCII,它可以追溯到 7 孔纸带(不计算奇偶校验)。

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 <CSZ> and <CZ> .自 7 孔纸带以来,我们已经走了很长一段路,根据我的经验,许多程序都认识到<CSZ><CZ>之间的区别。 Indeed, MacVim even recognizes the difference.事实上,MacVim 甚至认识到了其中的差异。 But no joy in GVim or in the GNOME Terminal?但是 GVim 或 GNOME 终端没有乐趣? 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).我遇到问题的另一个组合键是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> ).我不确定我的.vimrc中是否配置错误,或者它是否是 Vim 的真正问题,但映射后我无法得到<C-,>响应(例如: map <C-,>:TComment<CR> )。 FWIW, I have my leader key remapped to ; FWIW,我已将领导密钥重新映射到; . . Am I doing it wrong?我做错了吗? Or is there some other reason why Vim won't recognize the <C-,> key combo?还是有其他原因导致 Vim 无法识别<C-,>组合键?

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.我花了太多时间在谷歌上搜索和摆弄键映射,我即将宣布 Vim 不像我被认为的那样灵活......我什至无法配置它我习惯的键映射,其中一些我不愿意重新/忘记,因为它们在我每天使用的其他程序中工作。

It looks like the link you posted already answers your question regarding <Cb> vs. <CB> .看起来您发布的链接已经回答了您关于<Cb><CB>的问题。 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?).根据常见问题解答,您似乎对<C-,>也不走运,因为此组合键不在 Vim 可以检测到的 Ctrl-printable-key 和弦列表中(可能是因为它甚至不是可打印的ASCII 和弦?)。

Key combinations such as <CSw> are very un-Vim-like in that they undermine the efficiency of a modal editor.诸如<CSw>之类的组合键非常不像 Vim ,因为它们会破坏模态编辑器的效率。 Of course there are times when <CTRL> -escaped combinations are necessary (for example in insert-mode mappings such as <Cx> - <Co> for omnicompletion), but that's not the case for operations such as undo and redo.当然,有时<CTRL> -转义组合是必要的(例如在插入模式映射中,例如<Cx> - <Co>用于全完成),但对于撤消和重做等操作而言,情况并非如此。

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 的方式来做”,而不是试图让 Vim 屈服于您的意愿,会收获很多。

Try adding set nocompatable to your vimrc.尝试将set nocompatable添加到您的 vimrc。 without this you are basically running vi wich is much more limited than vim.没有这个,你基本上是在运行 vi,它比 vim 更受限制。 This should allow you to map <CSr> or <F11> or whatever else you want.这应该允许您 map <CSr><F11>或任何其他您想要的。 Tjameson is completely right.贾梅森完全正确。 it is much better to use the default mappings where they exist.在它们存在的地方使用默认映射要好得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM