Vi(m) tip #2: Entering greek/math symbols using vim digraphs

Alec Jacobson

October 14, 2009

weblog/

Lately I have been taking computer science/math class notes using vim. Since typing LaTeX is too cumbersome and not readily intuitive (you have to typeset it). I just use plain text. This is fine until I need to quickly type strange letters/symbols. I can do this in vim using digraphs. To see a list of available digraphs, in normal mode type:
:digraphs
To enter a digraph in insert mode simply hit <ctrl>+k then the two symbols to create the digraph. So to make the greek capital phi, Φ, you'd hit (in insert mode)
<ctrl>kF*
Below is a table of useful math and computer science digraphs.
symbol descriptionsymbolunicode (decimal)vim digraph (first type <ctrl>k)
plus minus±177+-
squared (superscript 2)²1782S
coproduct (big, tall Pi)8719*P
summation (big, tall Sigma)8721+Z
bullet operator (dot product)8729Sb
(square) root8730RT
infinity873400
Greek Letters
GammaΓ915G*
DeltaΔ916D*
ThetaΘ920H*
PiΠ928P*
SigmaΣ931S*
PhiΦ934F*
PsiΨ936Q*
OmegaΩ937W*
alphaα945a*
betaβ946b*
gammaγ947g*
deltaδ948d*
epsilonε949e*
etaη951y*
thetaθ952h*
kappaκ954k*
lambdaλ955l*
muμ956m*
piπ960p*
rhoρ961r*
sigmaσ963s*
sigma (alternative)ς962*s
tauτ964t*
phi*φ966f*
psi*ψ968q*
omega*ω969w*
dagger (sword)8224/-
double dagger (double sword)8225/=
left arrow*8592<-
up arrow8593-!
right arrow8594->
down arrow8595-v
Logic
for all (for any)8704FA
partial differential (curled little d)8706dP
there exists (backwards capital E)8707TE
logical and8743AN
logical or8744OR
therefore (triangle of dots)8756.:
because (upside-down triangle of dots)8757:.
Sets
Null set, empty set, var nothing, capital O slash8709/0
Null set, empty set, var nothing, capital O slashØ216O/
element of8712(-
contains as member8715-)
set intersect 8745 (U
set union8746U)
subset of (contained in)8834(C
superset of (contains)8835)C
subset of or equal to8838(_
superset of or equal to8839)_
concatenation, centered dot8728Ob
Calculus
integral S8747In
double integral S8748DI
line integral S with circle8750Io
Delta8710DE
Nabla8711NB
Equalities, inequalities, et al.
tilde operator (centered tilde, proportional)8764?1
approximately equal to8773?=
almost equal to8776?2
not equal to8800!=
less than or equal to8804=<
greater than or equal to8805>=
* I avoid these because they are double-width characters. In the document they are technically only one character put displayed they take up two character positions resulting in overlap in vim. Note: Greek letters are usually their Latin alphabet "equivalent" then star, with capitals taking capital (uppercase) Latin letters, likewise for lowercase. I included some (what I use most) here. Note:"Superscript" and "subscript" numbers are all [digit]S for Superscript and [digit]s for subscript. Note: If you don't find the character you want above, or by typing :digraphs and paging through supported digraphs, you can input a unicode character by its value in hex. Do this by typing <ctrl>v in insert mode then: u[4-hex-digit value] U[8-hex-digit value] Leading zeros may be omitted. Note: On some machines <ctrl>v means paste, in that case use <ctrl>q source Update: I found a useful list of unicodes for math symbols.