简体   繁体   中英

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 <CR> , but apparentlyVim 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 <CSZ> and <CZ> . 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 <Cb> vs. <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?).

Key combinations such as <CSw> 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 <Cx> - <Co> 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 <CSr> or <F11> or whatever else you want. Tjameson is completely right. it is much better to use the default mappings where they exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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