2

I've added the following to my ~/.vimrc:

autocmd FileType gitcommit setlocal spell

This is great, as when I'm editing a got commit message, I now have spell enabled.

However, our commit style guidelines state that the commit message (the first line, a subject line) should always be lowercase, triggering spell's detection.

Is there a way to express that spellcapcheck should disable for only the first line fo that scope?

1 Answer 1

1

You can achieve this by changing the filetype syntax using :syn-spell:

:sy[ntax] spell [toplevel | notoplevel | default]
    This defines where spell checking is to be done for text that is not
    in a syntax item:

    toplevel:   Text is spell checked.
    notoplevel: Text is not spell checked.
    default:    When there is a @Spell cluster no spell checking.

    For text in syntax items use the @Spell and @NoSpell clusters
    |spell-syntax|.  When there is no @Spell and no @NoSpell cluster then
    spell checking is done for "default" and "toplevel".

You can see $VIMRUNTIME/syntax/tex.vim as an example, similar to what was done this question.

But it not possible to control only the capitalization. You'll need to disable the entire spell check on the first word of the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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