Useful (Neo)Vim Digraphs

Written 4 days ago

What are digraphs?

Digraphs are used to enter characters that normally cannot be entered by an ordinary keyboard.

neovim docs

Basically, a bunch of useful symbols (or characters) that aren’t usually present on keyboards.

Like this nice cross/close: ×

Or this arrow: →

Or a snowflake: ※

Or some greek symbols: α β ε ζ

You get the idea.

Normally, when I need one (like say I wanted to add an arrow button to the “next”/“prev” buttons in the footer below), I’d just do

:digraph

to open up the list of builtin symbols and pick one that suits. This however, given the darkmode theme on my terminal and grayscale display of the symbols, is murder on my eyes. So, here’s a list of (potentially useful) digraphs nicely diplayed for future use:

chardigraphhexdecofficial name
@At0x4064COMMERCIAL AT
¤Cu0xa4164CURRENCY SIGN
©Co0xa9169COPYRIGHT SIGN
«<<0xab171LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
°DG0xb0176DEGREE SIGN
±+-0xb1177PLUS-MINUS SIGN
·.M0xb7183MIDDLE DOT
»>>0xbb187RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
×*X0xd7215MULTIPLICATION SIGN
÷-:0xf7247DIVISION SIGN
ΣS*03A30931GREEK CAPITAL LETTER SIGMA
ΦF*03A60934GREEK CAPITAL LETTER PHI
ΩW*03A90937GREEK CAPITAL LETTER OMEGA
αa*03B10945GREEK SMALL LETTER ALPHA
βb*03B20946GREEK SMALL LETTER BETA
εe*03B50949GREEK SMALL LETTER EPSILON
θh*03B80952GREEK SMALL LETTER THETA
λl*03BB0955GREEK SMALL LETTER LAMDA (aka LAMBDA)
μm*03BC0956GREEK SMALL LETTER MU
πp*03C00960GREEK SMALL LETTER PI
ρr*03C10961GREEK SMALL LETTER RHO
ϝm303DD0989GREEK SMALL LETTER DIGAMMA
!220168214DOUBLE VERTICAL LINE
‘620188216LEFT SINGLE QUOTATION MARK
‘920198217RIGHT SINGLE QUOTATION MARK
.9201A8218SINGLE LOW-9 QUOTATION MARK
9’201B8219SINGLE HIGH-REVERSED-9 QUOTATION MARK
“6201C8220LEFT DOUBLE QUOTATION MARK
“9201D8221RIGHT DOUBLE QUOTATION MARK
:9201E8222DOUBLE LOW-9 QUOTATION MARK
9”201F8223DOUBLE HIGH-REVERSED-9 QUOTATION MARK
/-20208224DAGGER
/=20218225DOUBLE DAGGER
oo20228226BULLET
,.20268230HORIZONTAL ELLIPSIS
%020308240PER MILLE SIGN
<120398249SINGLE LEFT-POINTING ANGLE QUOTATION MARK
>1203A8250SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
:X203B8251REFERENCE MARK
TM21228482TRADE MARK SIGN
ΩOm21268486OHM SIGN
<-21908592LEFTWARDS ARROW
-!21918593UPWARDS ARROW
->21928594RIGHTWARDS ARROW
-v21938595DOWNWARDS ARROW
<>21948596LEFT RIGHT ARROW
UD21958597UP DOWN ARROW
<=21D08656LEFTWARDS DOUBLE ARROW
=>21D28658RIGHTWARDS DOUBLE ARROW
==21D48660LEFT RIGHT DOUBLE ARROW
/022058709EMPTY SET
DE22068710INCREMENT
NB22078711NABLA
*-22178727ASTERISK OPERATOR
RT221A8730SQUARE ROOT
0(221D8733PROPORTIONAL TO
00221E8734INFINITY
=<22648804LESS-THAN OR EQUAL TO
>=22658805GREATER-THAN OR EQUAL TO
<*226A8810MUCH LESS-THAN
*>226B8811MUCH GREATER-THAN
0.22998857CIRCLED DOT OPERATOR
02229A8858CIRCLED RING OPERATOR
hh25009472BOX DRAWINGS LIGHT HORIZONTAL
HH25019473BOX DRAWINGS HEAVY HORIZONTAL
vv25029474BOX DRAWINGS LIGHT VERTICAL
VV25039475BOX DRAWINGS HEAVY VERTICAL
UT25B29650BLACK UP-POINTING TRIANGLE
uT25B39651WHITE UP-POINTING TRIANGLE
PR25B69654BLACK RIGHT-POINTING TRIANGLE
Tr25B79655WHITE RIGHT-POINTING TRIANGLE
Dt25BC9660BLACK DOWN-POINTING TRIANGLE
dT25BD9661WHITE DOWN-POINTING TRIANGLE
PL25C09664BLACK LEFT-POINTING TRIANGLE
Tl25C19665WHITE LEFT-POINTING TRIANGLE
Db25C69670BLACK DIAMOND
Dw25C79671WHITE DIAMOND
0m25CB9675WHITE CIRCLE
0o25CE9678BULLSEYE
0M25CF9679BLACK CIRCLE
0L25D09680CIRCLE WITH LEFT HALF BLACK
0R25D19681CIRCLE WITH RIGHT HALF BLACK
*226059733BLACK STAR
*126069734WHITE STAR
<H261C9756WHITE LEFT POINTING INDEX
>H261E9758WHITE RIGHT POINTING INDEX
0u263A9786WHITE SMILING FACE
0U263B9787BLACK SMILING FACE
SU263C9788WHITE SUN WITH RAYS
Fm26409792FEMALE SIGN
Ml26429794MALE SIGN
cS26609824BLACK SPADE SUIT
cH26619825WHITE HEART SUIT
cD26629826WHITE DIAMOND SUIT
cC26639827BLACK CLUB SUIT
Md26699833QUARTER NOTE
M8266A9834EIGHTH NOTE
M2266B9835BEAMED EIGHTH NOTES
Mb266D9837MUSIC FLAT SIGN
OK271310003CHECK MARK
XX271710007BALLOT X
-X272010016MALTESE CROSS

How do I use these digraphs?

Oh, basically in insert mode, just go <C-k> which is Ctrl + k btw and enter the characters like :X (note the capital) for snowflake. Easy peasy.

Some symbols may look weird on your browser; try in the editor.

If you’d like to use the hex representation just do (in insert mode) Ctrl + V, then enter u, finally followed by the hex code for the digraph.

Here’s a stackexchange link for entering different base inputs in vim: how-to-enter-non-ascii-characters

Bonus Content!

One usecase for digraphs is to use them as conceal characters. Say you have some go code like so:

func main() {
  doX()
  go doY()
  doZtoo()
}

func doX()
func doY()
func doZtoo()

you can use the ϝ symbol to substitue for the repeated func keyword using following:

syntax match goFunction 'func' conceal cchar=ϝ | set conceallevel=2

to turn the code into:

ϝ main() {
  doX()
  go doY()
  doZtoo()
}

ϝ doX()
ϝ doY()
ϝ doZtoo()

This one’s a freebie - don’t forget to experiment. Perhaps λ in python?

Don’t forget the builtin help: :h digraph or :h conceal

Have fun, cheers!