I'm trying to build a vimscript can be used with the Dvorak Simplified Layout. I.e., given that the keys on the keyboard plugged into the computer are laid out in the Dovark Simplified Layout (and the system's keyboard settings are set accordingly), I want to write a vimscript that will make vim use the Dvorak layout only in Insert mode: in all other modes, the keyboard layout will be QWERTY.

Here's what I have:

"Keys between the 0 and the backspace
noremap [ -
noremap { _
noremap ] =
noremap } +

"Keys from the tab till the end of the row
noremap ' q
noremap " Q
noremap , w
noremap < W
noremap . e
noremap > E
noremap p r
noremap P R
noremap y t
noremap Y T
noremap f y
noremap F Y
noremap g u
noremap G U
noremap c i
noremap C I
noremap r o
noremap R O
noremap l p
noremap L P
noremap / [
noremap ? {
noremap = ]
noremap + }

"Home row keys
noremap o s
noremap O S
noremap e d
noremap E D
noremap u f
noremap U F
noremap i g
noremap I G
noremap d h
noremap D H
noremap h j
noremap H J
noremap t k
noremap T K
noremap n l
noremap N L
noremap s ;
noremap S :
noremap - ,
noremap _ "

"Keys for the row below the home row
noremap ; z
noremap : Z
noremap q x
noremap Q X
noremap j c
noremap J C
noremap k v
noremap K V
noremap x b
noremap X B
noremap b n
noremap B N
noremap w ,
noremap W <
noremap v .
noremap v >
noremap z /
noremap Z ?

"Same as above but now for the console

"Keys between the 0 and the backspace
cnoremap [ -
cnoremap { _
cnoremap ] =
cnoremap } +

"Keys from the tab till the end of the row
cnoremap ' q
cnoremap " Q
cnoremap , w
cnoremap < W
cnoremap . e
cnoremap > E
cnoremap p r
cnoremap P R
cnoremap y t
cnoremap Y T
cnoremap f y
cnoremap F Y
cnoremap g u
cnoremap G U
cnoremap c i
cnoremap C I
cnoremap r o
cnoremap R O
cnoremap l p
cnoremap L P
cnoremap / [
cnoremap ? {
cnoremap = ]
cnoremap + }

"Home row keys
cnoremap o s
cnoremap O S
cnoremap e d
cnoremap E D
cnoremap u f
cnoremap U F
cnoremap i g
cnoremap I G
cnoremap d h
cnoremap D H
cnoremap h j
cnoremap H J
cnoremap t k
cnoremap T K
cnoremap n l
cnoremap N L
cnoremap s ;
cnoremap S :
cnoremap - ,
cnoremap _ "

"Keys for the row below the home row
cnoremap ; z
cnoremap : Z
cnoremap q x
cnoremap Q X
cnoremap j c
cnoremap J C
cnoremap k v
cnoremap K V
cnoremap x b
cnoremap X B
cnoremap b n
cnoremap B N
cnoremap w ,
cnoremap W <
cnoremap v .
cnoremap v >
cnoremap z /
cnoremap Z ?

But for some reason, pressing "ii" on the physical keyboard, which ought to jump to the beginning of the document (since in both Normal mode and Operator-Pending modes the "i" key maps to a "g"), vim goes into Insert mode. However, pressing "ig" on the physical keyboard does jump to the beginning of the document.

The problem persists whether on Linux or on Windows.

Why are the operating-pending mode maps not working? Vim help says that "noremap" remaps all modes except Insert, Console, Terminal-Job, and Lang-Arg.

New contributor
Sergey Nikolayvich is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Well, gg is a full command by itself, so operator mode is not involved here at all.

It's not like the first g is a command and then the second g is an operator. The g-something family of commands are simply two-character commands.

In order to have ii to map to ,gg, you actually need:

noremap ii gg

Though you'll probably need to map all the other i-something commands to their non-dvorak counterparts.

As recommended by @DBenKnoble in the comments, check out the dvorak.vim which is probably already installed in your vim, it probably does what you want and, if not, you can probably use it as a starting point.

Your Answer

Sergey Nikolayvich is a new contributor. Be nice, and check out our Code of Conduct.
 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.