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 (arguably) superior ergonomics. Using it with Vim, a highly customizable modal text editor, allows me to maximize productivity when either programming or writing.
Vim users who are considering the switch from QWERTY to Colemak are confronted with the dilemma as to whether it is worthwhile to remap Vim's default binding to maintain the key positioning under Colemak. Both options have various benefits and challenges. For those that choose to add Vim mappings for Colemak, there are different ways of doing so each with its own tradeoffs.
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
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
.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
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. For this to work, your Vim must have
been installed with the
langmap version. This may not be the case for some
minimalist Vim installs. Note that my version below maps
p and leaves
the semicolon alone rather
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
for changing the case of everything until the end of the word.
nnoremap <leader>f ve~
noremap, you can keep this and still press
<leader>f to trigger the
mapping albeit the position of the
f key has changed.
langmap, you need the following instead if you want trigger the mapping
<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
set langnoremap can be used alongside
langmap to make
langmap behave more
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.