12

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.

Gordon Gustafson
  • 40,133
  • 25
  • 115
  • 157
  • 2
    I hesitate to ask what kind of situation warrants this, but I will. What kind of situation warrants this? :D – Ry- Dec 24 '12 at 19:58
  • @minitech Dvorak is optimized for typing, but Vim commands were selected with Qwerty in mind. Best of both worlds. :) – Gordon Gustafson Dec 24 '12 at 20:38
  • What exactly is the problem though? – rid Dec 24 '12 at 22:00
  • vim commands work quite fine in Dvorak too IMHO. `dw` is not that convenient, but `dex` does the job. `cw` can usually be replaced with `ce`. Some keys have better locations in Dvorak, eg. `x`. According to my experience, relearning common Linux/Windows shortcuts such as Ctrl-C, Ctrl-V etc. only takes a short time to become fluent. – nrz Dec 24 '12 at 22:13
  • I only picked up Vim after learning Dvorak but nothing seems particularly unusual to me. HJKL even are basically functional an J and K are next to each other and H is to the left of L. In other words, why not switch your machine over (or get a Dvorak keyboard!)? – dash-tom-bang Dec 27 '12 at 09:29

2 Answers2

9

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.

Dmytro Sirenko
  • 5,003
  • 21
  • 26
  • 1
    How do I make this work for an OS already set to "dvorak"? In other words, I still have to switch back from dvorak to qwerty now, whenever I open vim. Then, when I exit vim and return to the terminal, I must still switch to dvorak. – Chris Dec 30 '17 at 19:34
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

Huluk
  • 864
  • 6
  • 18