Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does VIM highlight some words?

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")

like image 452
Perica Zivkovic Avatar asked Jun 09 '12 18:06

Perica Zivkovic


People also ask

Why are some words highlighted in Vim?

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.

Why is text highlighted red in Vim?

Similarly, errors are generally highlighted in red color and it looks like vim does not know how the syntax should be handled for /etc/sysconfig/named . However, highlighting of error messages is done with the help of Error and ErrorMsg highlight groups. So try to highlight groups as shown below.


2 Answers

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.

like image 144
Shahbaz Avatar answered Sep 27 '22 19:09

Shahbaz


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.)

like image 28
Ingo Karkat Avatar answered Sep 27 '22 21:09

Ingo Karkat