Vim keymap for mathematical monospace font

By 0x7df, Fri 16 July 2021, modified Fri 16 July 2021, in category Programming

utf, vim

Keymap concept

Vim lets you create keymaps that map keyboard characters to other characters, and which you can load and unload while editing. A keymap

will translate one or more (English) characters to another (non-English) character


:help mbyte-keymap

for info.

There are built-in keymaps for many languages; for example:

:set keymap=hebrew

The status bar in Vim will show <heb> on the right hand side, which is the short name for the keymap.

While it's loaded, typing for example abcdef gives the characters שנבגקכע.

To unload: :set keymap=.

Built-in keymaps

The search path for keymaps is the Vim runtimepath; to list all available keymaps:

:echo globpath(&rtp, "keymap/*.vim")

This lists the paths to the keymap files that Vim is aware of, so we can find them:

ls -c /usr/local/share/vim/vim82/keymap/hebrew*.vim



In this list there are two keymaps, hebrew and hebrewp, for each of which several encodings are available. Running :set keymap=hebrew selects the one appropriate for the encoding in use; in this case hebrew_utf-8.vim, given we have run :set encoding=utf-8 previously.

File format

To print the first few lines of the file:

head -15 /usr/local/share/vim/vim82/keymap/hebrewp_utf-8.vim


" Vim Keymap file for hebrew
" Maintainer  : Ron Aaron <>
" Last Updated: Wed 28 Feb 2001 21:28:51
" This is the standard Israeli keyboard layout with (my nonstandard locations
" for) niqud, for utf:

" Use this short name in the status line.
let b:keymap_name = "heb"
a   <char-0x5e9>    " ש - shin
b   <char-0x5e0>    " נ - nun
c   <char-0x5d1>    " ב - bet
d   <char-0x5d2>    " ג - gimel
e   <char-0x5e7>    " ק - qof
f   <char-0x5db>    " כ - kaf

The let b:keymap = ... line defines the short name that appears in the status bar. The lines after loadkeymap define the mappings, one per line, with whitespace separating the two items, and comments starting with ".

Creating a mapping for mathematical monospace characters

User-level mappings can be added to the run-time path, see :help rtp for a list of default locations. I created ~/.vim/keymap/monospace_utf-8.vim with contents:

let b:keymap_name = "mono"

a 𝚊
b 𝚋
c 𝚌
d 𝚍
e 𝚎
f 𝚏

etc. To enter a monospace mathematical character into the keymap file, type: <ctrl>-v to tell Vim to the insert the next (non-digit) character literally, then U to insert a hex code, the the UTF-8 code for the symbol; e.g. 0001d68c for 𝚌 (see Although much easier to copy and paste the characters from


2021-07-20T11:55:59.993Z | 0x7df:

Relevant: How to get formatted text in unicode at the command-line, using `unifont` from the Perl `Unicode::Tussle` module. Also warns against using formatted text on e.g. Twitter as it might not render properly on all devices and might not be picked up by screen readers.

Add comment