ask Vim why the word under the cursor is misspelled

23 views
Skip to first unread message

Adam Monsen

unread,
May 17, 2023, 3:41:28 PM5/17/23
to vim...@googlegroups.com
Is there a way to directly ask the Vim spell checker precisely why the word under the cursor is misspelled?

It took me a bit to figure out how it paints a blue background behind bare words on a line because they are not capitalized. For example:

foo

I can figure it out pretty easily from the suggestions listed by typing z= in normal mode (while my cursor is on the highlighted non-capitalized word) because the first suggestion is "Foo" with a capital F.

It would be handy to be able to get this information explicitly in Vim script, similar to how I can use synIDattr() and synIDtrans() to query the name and detail of the syntax highlighting group in effect at the current cursor position. Getting the group "SpellCap" or something like "word [foo] is not capitalized" would be helpful. I guess I'd prefer the first because it is unambiguous and ":help SpellCap" works as expected.

Thanks!
-Adam


Related:

Bram Moolenaar

unread,
May 17, 2023, 5:14:33 PM5/17/23
to vim...@googlegroups.com, Adam Monsen

Adam Monsen wrote:

> Is there a way to directly ask the Vim spell checker precisely why the word
> under the cursor is misspelled?
>
> It took me a bit to figure out how it paints a blue background behind bare
> words on a line because they are not capitalized. For example:
>
> foo
>
> I can figure it out pretty easily from the suggestions listed by typing z=
> in normal mode (while my cursor is on the highlighted non-capitalized word)
> because the first suggestion is "Foo" with a capital F.
>
> It would be handy to be able to get this information explicitly in Vim
> script, similar to how I can use synIDattr() and synIDtrans() to query the
> name and detail of the syntax highlighting group in effect at the current
> cursor position. Getting the group "SpellCap" or something like "word [foo]
> is not capitalized" would be helpful. I guess I'd prefer the first because
> it is unambiguous and ":help SpellCap" works as expected.

You can use spellbadword() for that.

--
Nothing is fool-proof to a sufficiently talented fool.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Adam Monsen

unread,
May 17, 2023, 7:01:33 PM5/17/23
to Bram Moolenaar, vim...@googlegroups.com
Bram Moolenaar wrote:
You can use spellbadword() for that.
 
Oh, nice! I completely missed that. Works like a charm.

\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///

 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

Good idea. Done.
Reply all
Reply to author
Forward
0 new messages