Why does VIM highlight some words?
Asked Answered
U

3

17

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

Color scheme 1

with another colorscheme

Color scheme 2

I'm using spf13-vim configuration and connecting remotely with Putty.

VIM is correctly assuming this file to be a python file (:set filetype returns "python")

Umberto answered 9/6, 2012 at 18:31 Comment(4)
I was wondering this myself recently!Attrition
Wow, that looks horribly annoying, especially the colored version... What does vim think the type of the file is? (do :set filetype to find out)Commissioner
filetype=python which is correct :)Umberto
See also "How do I edit out the colored background that appears around some text in VIM's Jellybean color scheme?"Thermolabile
W
27

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.

Wargo answered 9/6, 2012 at 18:47 Comment(2)
@PericaZivkovic, you're welcome. You should remember this feature, it sometimes comes in handy. For example when writing a document with LaTeX, you might want to turn it once you are finished, get a quick review, and then turn it off again.Wargo
Some more details on the why from the original question: If something is syntax highlighted, you can position the cursor over that word and run a command to learn exactly why. For words highlighted by the spell checker, the suggestions you get by typing z= in normal mode should give you clues as to why. This post includes links to more info about both syntax highlighting and spell check: groups.google.com/g/vim_use/c/QgzG2h9dKQ0Ashkhabad
M
4

Most filetypes (like python) in Vim come with a syntax that defines highlight groups (see them via :highlight). A colorscheme then provides combinations of foreground / background color and/or formatting like bold and italic, for terminals, color terminals, and/or GVIM.

Choose a colorscheme that you find visually appealing; some come with Vim, many more can be found on the Internet, most at http://www.vim.org/.

If you're just annoyed by one or two minor things in a particular colorscheme, you can modify the items via the :highlight command. To disable a highlighting, use, e.g.

:highlight clear Statement

or (when the group is linked to another group, effectively inheriting its appearance)

:highlight link Statement NONE

(These must be issued after the :colorscheme command that sets your preference.)

Membranous answered 9/6, 2012 at 18:55 Comment(2)
it is not colorscheme, I tried lots of them and they all had the same, it was spell check like suggested by Shahbaz but thanks for the tipUmberto
Yeah, good answer, I didn't realize that. Spell checking is useful, in general. In the console Vim, though, the colors aren't particular aesthetic, for lack of colors. In GVIM, spell errors show up as squiggly lines, much better. Or read up how to enable 256 colors with PuTTY and choose a high-color colorscheme; that has nicer colors.Membranous
C
0

I have came across two kinds of highlight that I don't like.

1.indent highlight and tab arrow reminder, you can solve it by adding

let g:indent_guides_enable_on_vim_startup = 0
set nolist

to ~/.vimrc.local

2.highlight the usual words, like Chinese words and wrong spell words, you can solve it by adding

set nospell

to ~/.vimrc.local

Cochineal answered 17/9, 2017 at 14:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.