开发者

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. 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开发者_StackOverflow社区'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.


Try adding set nocompatable to your vimrc. without this you are basically running vi wich is much more limited than vim. This should allow you to map <C-S-r> or <F11> or whatever else you want. Tjameson is completely right. it is much better to use the default mappings where they exist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜