Wednesday, May 17, 2023

Re: ask Vim why the word under the cursor is misspelled

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 -- Bram@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 ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20230517211425.CC2D01C0C46%40moolenaar.net.

No comments: