Accented and other unicode characters in groff/troff

[linkstandalone]

I've already gotten a lot of questions about this, and while I might do a video on it later, I might as well put the answer here for those who are interested.

By default groff and troff have no such compatibility with accented characters, which, if you had the misfortune of being born to a language besides the glorious American tongue, makes writing quite documents in groff difficult.

Obviously there are many ways of bridging this gap, some you could easily invent on your own, but there are indeed built in escape sequences for most characters needed for other languages in the Latin alphabet.

Check out the documentation here in the GNU manuals on escape sequences not only for adding accents to characters, but also for needed symbols in other languages like the German ß, the Spanish ¿ or Icelandic/Old English þ and ð.

If you're like me and you don't want to bother typing such silly escape sequences out, you could always automate their appearance in vim whenever you type the corresponding character. Below I have the lines for the acute characters.

autocmd Filetype groff inoremap á \*[']a
autocmd Filetype groff inoremap Á \*[']A
autocmd Filetype groff inoremap é \*[']e
autocmd Filetype groff inoremap É \*[']E
autocmd Filetype groff inoremap í \*[']i
autocmd Filetype groff inoremap Í \*[']I
autocmd Filetype groff inoremap ó \*[']o
autocmd Filetype groff inoremap Ó \*[']O
autocmd Filetype groff inoremap ú \*[']u
autocmd Filetype groff inoremap Ú \*[']U

You can add what you want.

Be also sure that vim is properly detecting your filetype, adding autocmd BufRead,BufNewFile *.ms,*.me,*.mom set filetype=groff beforehand will do the trick for .ms, .me and .mom files.