How to set a colorscheme that still shows spelling errors?

I am looking for two combined effects that I can acquire separately but not yet together.

  1. Set Colorscheme alone: OK. If I want highlights on spelling mistakes I can use a .vimrc file with this single line: set spell. So if I write a mwe file (mwe.vim) with a name in it as text content: John Morelock. Then the result is that vim recognizes John as a proper word, and does not highlight it, but then does properly highlight the last name. All OK up to here.

  2. Set Spelling alone: OK. As another task I would like to add a colorscheme, for example solarized. So I set colorscheme solarized as a single line in the .vimrc. All fine here. I open up the same previous file, and it shows the file with specific colorscheme. If I put both lines together, setting colors and spelling, all is OK here.

  3. Set Colorscheme and Spelling together: not always OK. The issue is that both previous procedures working together works under certain circumstances, such as with the mentioned colorscheme solarized, but not with another half of colors, at least in my specific case. I would like, for instance to use colorscheme adrian with spelling, but as soon as I use these two together, all of it stops working. To make adrianwork, the colorscheme line alone is not enough. Instead I have to add the line `set termguicolors', but this may be cancelling out my spelling to not show.

One hack is to eliminate schemecolors and fiddle with my terminal colors. Useful, but still my ideal solution would be to be able to choose colorschemes: adrian, matrix, onedark, or whatever. However, I would point out that many people seem to be asking questions about how to set coloring and highlights, so I would ask both a specific and a general question. I have browsed extensively, both in :h colorscheme and StackExchange. Where should one prioritize a search to begin solving this simple problem?

Where could I start looking for my specific problem? Both via web, and my pc.

How to set good practices for setting colors, spelling and in general?

Edit: I should add that I am not being able to use the adrian colorscheme with a single line invocation of setting colorscheme. To make it valid I have to add an extra line such as set termguicolors but this does not keep the spelling working properly.

  • Could I improve on the question to receive more answer/comments? – nilon Dec 16 '18 at 0:18
  • Its a little confusing—are you trying to use different colorschemes? One for spelling and one for, well, everything else? At that point I would just highlight the spelling groups with whatever you want (after loading your colorscheme). – D. Ben Knoble Dec 16 '18 at 6:13
  • 1
    Additionally, we discourage more than one question per post in general, and your questions at the end are off topic and too broad, respectively, imo. Resource requests is not usually something StackExchange does; « general practices » simply is not a specific problem. – D. Ben Knoble Dec 16 '18 at 6:15
  • Nice @D.BenKnoble! I want to use colorschemes where the highlight is visible. For x reason, in my pc, half of the colorschemes don't show highlight. I was seeking for a Q&A that could be of help for people in the future when they want to define these two topics and learning from scratch. I am used to reading general practices in LaTeX SE, like everyday workflow, that's why I thought it would be OK to ask on this configuration. I can also remove the second question, I'll give it some thought. – nilon Dec 17 '18 at 12:19

I'm going to take a stab in the dark and suggest that your configuration is probably resulting in no highlighting.

You can check this with the command :verbose highlight SpellBad: if the xxx at the start of the line is not highlighted, then badly spelled words won't be highlighted, either.

If this is the problem, then spelling commands should still work correctly: you should still be able to jump to the next and previous error with ]s and [s, etc.

You can fix this by setting the highlighting yourself. You can simply add :highlight commands to your vimrc, but a better way is probably to use a ColorScheme autocommand. e.g.:

augroup my_colours
  autocmd ColorScheme adrian hi SpellBad cterm=reverse
augroup END

Put this before the colorscheme line in your vimrc.

See :help :highlight and :help ColorScheme for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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