Spellcheck and abbreviations which include digits

12 views
Skip to first unread message

BPJ

unread,
Jul 26, 2025, 9:28:28 AMJul 26
to vim_use
The usecase:

When writing on historical subjects I commonly use the abbreviations "1stC, 2ndC, 3rdC, 4thC, ...; 1stM, 2ndM, 3rdM, 4thM, ..." where "C" stands for "century" and "M" stands for "millennium".

The problem:

In Markdown files (and probably everywhere) when 'spell' is activated "stC, ndC, rdC, thC" get highlighted as wrong while the number before them get highlighted as, well, numbers. I tried to add 1..30 + the right suffixes to my spellfile to no avail. I obviously can add "stC" and so on but I want "1thC, 2thC, 3thC, 4stC, ..." to be flagged as wrong, and indeed those suffixes when not preceded by an integer as wrong.

Tried fix:

Adding '\v<\d*[123]th[CM]>', '\v%(<\d+@<!)th[CM]>' etc highlighted as SpellBad with matchadd() or to a file in my ~/.vim/after/syntax directory. While this kind of works it has the slight downside that it's active when 'spell' is not and the serious downside that I can't use =z on them.

Better fix:

Any?

TIA,

/Benct

Reply all
Reply to author
Forward
0 new messages