Why does VIM highlight some words?

后端 未结 3 1374
小蘑菇
小蘑菇 2021-02-07 10:12

I noticed that with different colorschemes VIM is underlining/highlighting some words. Why is this and how to turn it off ?

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 10:16

    It seems like your Vim is doing spell-checking for you. You can turn this off by adding

    set nospell
    

    in your .vimrc file. To turn it back on in a file, you can do:

    :setlocal spell spelllang=en_us
    

    for spell-checking with American English. :setlocal changes settings for current buffer, while :set makes the changes for all currently open buffers. You can read more about how spell-checking with Vim works here.

    It may be useful for you to automatically enable spell checking for certain files. For example, to enable spell checking in .tex files, you can add the following to your .vimrc:

    " Enable spell checking when opening .tex files
    autocmd!
    au BufNewFile,BufRead *.tex setlocal spell spelllang=en_us
    " Or if you have filetype detection enabled:
    " au FileType tex setlocal spell spelllang=en_us
    

    Note that autocmd! clears the previously defined au commands and is needed only once.

提交回复
热议问题