Posted by Xudong Zheng on December 28, 2017
Colemak is one of the most popular alternatives to the standard QWERTY keyboard layout due to its ergonomics.
Vim users who are considering the switch from QWERTY to Colemak have to consider whether it is worthwhile to remap Vim keys to maintain the key positioning under Colemak. Doing so have both benefits and drawbacks. For users that choose to remap Vim keys, there are several different ways of doing so.
Keeping the default Vim bindings can be very beneficial for users who frequently
work on remote machines with only the standard Vim configuration, allowing them
to use Vim with the same muscle memory. This is perhaps the simplest solution
although a major drawback is that the right index finger is responsible for all
4 hjkl
keys. While I do not rely on hjkl
to navigate within Vim, I use them
often enough that using Vim's default bindings ends up being inconvenient.
My preferred solution is using noremap
to map Colemak keys to the
corresponding QWERTY keys. This works well for me because I am able to deploy my
personal .vimrc
to remote servers that I administer. You can take a look at my
complete .vimrc file to see what exactly I've done
(along with my other customizations).
noremap d g
noremap e k
noremap f e
noremap g t
noremap i l
noremap j y
noremap k n
noremap l u
noremap n j
noremap o p
noremap p r
noremap r s
noremap s d
noremap t f
noremap u i
noremap y o
noremap D G
noremap E K
noremap F E
noremap G T
noremap I L
noremap J Y
noremap K N
noremap L U
noremap N J
noremap O P
noremap P R
noremap R S
noremap S D
noremap T F
noremap U I
noremap Y O
As a simple example, you would use n
instead of j
to go to the next line
since n
in Colemak uses the j
QWERTY key.
These mappings only affect verbs and modifiers; they do not affect text objects.
Deleting inner sentence is sus
under Colemak compared to dis
under QWERTY.
In this example the verb d
and modifier i
are positionally the same between
QWERTY and Colemak whereas the text object s
uses a different physical key but
maintains its logical meaning.
An alternative solution is using langmap
. Keep in mind that minimalist Vim
builds may not include langmap
support. My particular version below maps o
to p
and leaves the semicolon alone rather o
to ;
and ;
to p
.
set langmap=dg,ek,fe,gt,il,jy,kn,lu,nj,pr,rs,sd,tf,ui,yo,op,DG,EK,FE,GT,IL,JY,KN,LU,NJ,PR,RS,SD,TF,UI,YO,OP
When using this approach, everything is mapped verbatim from QWERTY to Colemak.
Deleting inner sentence is sur
for example.
I strongly prefer the noremap
approach as your other Vim mappings needs
minimal changes to accommodate Colemak.
noremap
, the left hand side of a mapping is what you type and the right
hand side is what you would use on a default Vim install.langmap
, the left hand side of a mapping needs to be mapped to be
QWERTY and the right hand side takes the langmap
value into account.This is easy to demonstrate with a simple example. Suppose you had <leader>f
for changing the case of everything until the end of the word.
nnoremap <leader>f ve~
Using noremap
, you can keep this and still press <leader>f
to trigger the
mapping albeit the position of the f
key has changed.
With langmap
, you need the following instead if you want trigger the mapping
with <leader>f
. Essentially you need to convert the left hand side to QWERTY
whereas the right hand side is the non-sensible converted QWERTY sequence.
nnoremap <leader>e vf~
In my opinion, the noremap
mapping approach makes much more sense: the left
hand side is what you are typing and the right hand side follows standard Vim
behavior.
set langnoremap
can be used alongside langmap
to make langmap
behave more
like noremap
described above. I've ran into some edge cases where behavior is
inconsistent though some of these could be attributed to some bug in Vim rather
than the expected behavior.