Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spelling errors hidden while highlighting line in vim

Tags:

vim

When there's a misspelling (with set spell), it highlights it red (good!), but when the line is highlighted as my current line the red goes away (bad). Removing set cul fixes the problem, but how do I keep the word marked red while being highlighted? I may have multiple words misspelled on a line and also while typing the misspellings are hidden until I go to the next which kinda sucks.

vimrc: https://gist.github.com/OscarGodson/d1b05d52df4ff160b891
colorscheme: https://github.com/tomasr/molokai

like image 659
Oscar Godson Avatar asked Feb 21 '13 21:02

Oscar Godson


2 Answers

1) one could change the vim color scheme, or the SpellBad highlight scheme; one example of the second case is to add in vimrc the following,

hi clear SpellBad
hi SpellBad cterm=bold

2) (not a solution) someone might find 'spell checking while composing' is a bit annoying / distracting and prefer switching the spell checking off until they finish writing the article.

like image 70
Hao Wang Avatar answered Nov 10 '22 05:11

Hao Wang


The problem is that the cursorline highlighting has priority over the syntax highlighting (spell errors belong to that), and that cannot be changed. (You can only specify the priority with the newer matchadd() functions.)

I've once raised this issue for error highlighting, but nothing came out of it. (I'd still like to implement a patch for that one day.)

The problem is only about overlap of background highlighting; in GVIM, most color schemes use the undercurl attribute to avoid that issue. In the console, you can only change the highlighting to foreground color, italic or bold attributes to work around it.

workaround

One clever workaround involves swapping the foreground and background colors while adding the reverse attribute: Turn

hi SpellBad cterm=NONE ctermbg=red ctermfg=white

to

hi SpellBad cterm=reverse ctermbg=white ctermfg=red

These two changes cancel each other out normally, but on a CursorLine, the foreground color now contributes to the coloring, turning hard-to-read white-on-cursorline to red-on-cursorline.

like image 39
Ingo Karkat Avatar answered Nov 10 '22 04:11

Ingo Karkat