Make Vim use Dvorak keybindings ONLY in insert mod

2019-02-16 17:09发布

问题:

I would like to use the Dvorak layout when I am typing in Vim. However, I would like all of my shortcuts to stay the same (behave as if keyboard is Qwerty in command mode). I have tried using this:

set langmap=q',e.,rp,ty,yf,ug,ic,or,pl,[/,]=,aa,so,de,fu,gi,hd,jh,kt,ln,\\;s,'-,z\\;,xq,cj,vk,bx,nb,mm,.v,/z,-[,=],Q\\",W<,E>,RP,TY,YF,UG,IC,OR,PL,{?,}+,AA,SO,DE,FU,GI,HD,JH,KT,LN,:S,"_,Z:,XQ,CJ,VK,BX,NB,MM,<W,>V,?Z      

to map my qwerty keys to dvorak while in insert mode, but I found that it interfered with some of my shortcuts. I would like to do this while keeping my keyboard mapped to qwerty on the rest of my OS (Windows 7). How can I achieve this with Vim? What does langmap actually do? (had trouble finding documentation)

It would be nice if the keyboard was dvorak in search mode, but that's more of an added bonus.

回答1:

I would like to do this while keeping my keyboard mapped to qwerty on the rest of my OS (Windows 7)

– so just use :set keymap=dvorak (dvorak.vim may be found in default Vim configuration on Ubuntu in vim73/keymap/, it must be available on Windows too). It does what you describe: Dvorak method is used in insert mode and search mode.



回答2:

The documentation for langmap can be found at

:help langmap

[..] When you are typing text in Insert mode the characters are inserted directly. When in command mode the 'langmap' option takes care of translating these special characters to the original meaning of the key. [..]

but if you are using qwerty keys and only want dvorak in insert mode, you may have to use keymap instead