Unable to turn off spelling for words followed by punctuation characters

15 views
Skip to first unread message

Steve Dondley

unread,
Sep 7, 2021, 7:52:29 AM9/7/21
to vim_use
I'm have a tough time turning off spell checking for words that immediately follow a punctuation character.

For example, I don't want any of the words in this path to be spellchecked:

/kjkj/kasjdf/kjdsf

So I did:

syn match UrlNoSpell '[\/]w\+' contains=@NoSpell

This works.

However, this doesn't:

syn match UrlNoSpell '[:punct:]w\+' contains=@NoSpell

Even this doesn't work:

"syn match UrlNoSpell '[\/\.]w\+' contains=@NoSpell

Any words preceded with a period are still spell checked. I tried with both magic and no magic. Nothing works.

I obviously don't know how character classes work in vim. Didn't find anything in :h regex that gave me any hints as to what the problem might be. Can someone clue me in?

Steve Dondley

unread,
Sep 7, 2021, 8:00:28 AM9/7/21
to vim_use
OK, looks like the type of quotes makes the difference. With double quotes, things seem to be working now.

BPJ

unread,
Sep 7, 2021, 8:55:30 AM9/7/21
to vim_use
Den tis 7 sep. 2021 14:01Steve Dondley <sdon...@gmail.com> skrev:
OK, looks like the type of quotes makes the difference.

I don't think syntax pattern strings follow the rules for ordinary quoted strings since you can use any punctuation character as delimiter just like with :s, and like with :s forward slash seems to be the standard, but if the pattern contains forward slashes you can use some other character which does not occur in the pattern.

However it is not clear to me whether single quotes are in any way special here. It seems :h :syn-pattern does not mention anything on it. Does anyone know? (I'm curious! :-)




Jürgen Krämer

unread,
Sep 15, 2021, 2:50:18 AM9/15/21
to vim...@googlegroups.com
Hi,

Steve Dondley schrieb am 07.09.2021 um 13:47:
> I'm have a tough time turning off spell checking for words that immediately follow a punctuation character.
>
> For example, I don't want any of the words in this path to be spellchecked:
>
> /kjkj/kasjdf/kjdsf
>
> So I did:
>
> syn match UrlNoSpell '[\/]w\+' contains=@NoSpell
>
> This works.
>
> However, this doesn't:
>
> syn match UrlNoSpell '[:punct:]w\+' contains=@NoSpell

the syntax for a character class inside a collection is wrong. You
need to use two sets of brackets, i.e.,

syn match UrlNoSpell '[[:punct:]]\w\+' contains=@NoSpell

(I assume the missing backslash before w\+ was just a typo in your mail
or the result of some backslash interpretation by you mail client.)

Regards,
Jürgen


Reply all
Reply to author
Forward
0 new messages