Digraph

About the Tool

This tool can be used to simplify the process of entering special characters. Instead of remembering obscure alt-codes like Alt-0176 for a degree sign, Alt-0233 for an e with an acute accent or Alt-230 for the Greek letter mu, these can be entered by hitting a standard short-cut key (e.g. Win+K) followed by two characters that are logically chosen to represent the symbol. For the examples above, the degree symbol (°) uses the characters DG, the e with an acute accent (é) is e' and the letter mu (μ) is entered as m* (all Greek characters can be typed as the Latin equivalent followed by *).

The tool can also be useful on laptops that don't have a numeric keypad, upon which the Alt key codes rely.

There are some examples of common digraphs in docs/digraph_table.xlsx (the first section is standard suffixes such as ' for an acute accent or * for Greek letters, the others show specific digraphs). There's also a PDF of this if you don't have anything that will read xlsx spreadsheets or just want a print-out.

The digraphs were taken from those used in Vim text editor; a full list is available at http://vimhelp.appspot.com/digraph.txt.html#digraph-table or in a slightly more cryptic format in entries.txt - the first column is the digraph and the second column is the unicode character number (in hexadecimal if prefixed with 0x, otherwise in decimal).

The special digraph "VE" will show the version number of the application. Digraphs are case sensitive: w* produces ω; W* produces Ω. If a digraph isn't recognised, the tool will try swapping the letters round to see if a valid digraph exists in the opposite order (for example, \/ is an invalid digraph, but /\ is the digraph for ×, so if you type \/, the tool will assume you meant /\). If no digraph can be found in either order, an error message is printed.

Digraphs will only work if the font in use in whatever application you're typing into supports the particular character. Otherwise you'll get a blank space or a symbol showing an invalid character. Of course some symbols may produce deliberate blank spaces (e.g. NS produces a non-breaking space character).

Note that the tool works by inserting the symbol into the clipboard and then sending Shift-Insert to the last active window. This has a few implications:

  1. It will overwrite whatever was previously in the clipboard.
  2. If Windows is going a bit slowly, the paste will fail as the window switch won't have happened in time. In this case, just press Ctrl-V or Shift-Insert manually.
  3. Applications that don't accept Shift-Insert as paste won't paste the character in so you'll have to do it manually (or configure a custom paste command).

You can override the pasting commands using config/settings.ini. With the default configuration, Ctrl-R, + is sent if the last active window included the text "GVIM" in the title. Otherwise Shift-Insert is sent. If you want to change the default to be Ctrl-V, then change +{INS} to ^v in settings.ini. In my experimentation, Shift-Insert seems to work in most applications, hence choosing it as the default.

The software is open source, released under the MIT licence. It can be downloaded from github.

Keyboard Shortcut Prefix

To create a keyboard shortcut, there are two methods that work equally well:

The second option is probably a bit faster, but either should work. Autohotkey has the additional advantage that the script can ensure that the digraph window is brought into focus as soon as it appears.

Choosing the Window Size

There are two versions of the digraph window. The default version is a very small and unobtrusive window with a box into which you can type the digraph. It looks like this:

It's also possible to show a larger window with some examples of possible digraphs:

Once you press the first letter of your chosen digraph, the examples change to show the available digraphs starting with that letter:

To use the larger window, there are two options:

  • Pass --large as a command line argument: this can be done in the Windows shortcut configuration or the autohotkey script as required. If you use the autohotkey script in the docs folder, Win+J will open the large window and Win+K will open the smaller one.
  • Edit config/settings.ini and add this:

[UI]
LargeWindow = true

Binary Versions

There are a several builds included in the releases:

  1. Dynamic linking, minimised selection of DLLs to save space
  2. Dynamic linking, all Qt DLLs
  3. Static linking (smallest file, slowest start)

In most cases, it probably doesn't make much difference which one you use: they all do the same thing. The statically compiled version (suffix static) contains everything needed within one binary file and is a much smaller download than the other versions. However, it seems to be a little slower to start than the dynamically linked versions.

The dynamically linked versions include the DLLs that are required by the application. The resulting download size was huge, so in the minimised selection version (suffix min-dlls), I've tried to remove any that didn't seem necessary. If that doesn't work on your PC or you have no concerns about space / bandwidth, the version with all the DLLs should be a safe bet.

Other Operating Systems

The tool is written using the Qt graphical user interface library. In principle, it should be straightforward to port it to Linux or Mac OS X. The only Windows-specific parts of the code are in windows_specific.cpp and are responsible for sending the "paste" keyboard shortcut to the last active application.


This website is free, but costs me money to run. If you'd like to support this site, please consider making a small donation or sending me a message to let me know what you liked or found useful.