4

That is, one that would make :echo good('crazy') print '1'.

6

You can use the spellbadword function:

spellbadword([{sentence}])
    ...
    With argument: The result is the first word in {sentence} that
    is badly spelled.  If there are no spelling mistakes the
    result is an empty string.

    The return value is a list with two items:
    - The badly spelled word or an empty string.
    - The type of the spelling error:
            "bad"           spelling mistake
            "rare"          rare word
            "local"         word only valid in another region
            "caps"          word should start with Capital
    Example: 
            echo spellbadword("the quik brown fox")
           ['quik', 'bad'] 

So:

function Good(word)
   return len(spellbadword(a:word)[0]) == 0
endfunction

Then:

:echo Good('crazy')
1
:echo Good('crzy')
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.