0

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.

0

gg is not normal mode g + motion g; it is a full normal mode mapping on its own, and would have to be mapped like this:

nnoremap ii gg

However, I think your whole approach is flawed and will cause problems. At least, Dvorak layouts usually are implemented differently, with :help 'keymap'. See Using Vim with the Dvorak keyboard layout, and check out $VIMRUNTIME/keymap/dvorak.vim.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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