2

While using gVim on my Windows 10 machine at work, I discovered and started using the amazing spell checker when writing markdown. In gVim, misspelled words are underlined with the red squiggly everyone is familiar with.

At home on my Ubuntu machine, I realized the red squiggly only works in gVim, not in my terminal. I looked through the help files and it sounds like highlighting is the default way vim points out spelling errors. Yet, none of my misspelled words are highlighted. This is a problem for me because although I have gVim installed on this machine, a prefer to use vim in the terminal.

I have tried starting vim without my config file and the spell check does work (it highlights bad words). When I start vim with my config, it does not highlight words, even when I enter :set spell.

vim version: 8.0
vim plugins: surround.vim,solarized.vim
terminal: Xfce Terminal
current contents of vimrc

Update:

Spell-check highlighting works when I comment-out colorscheme solarized in my vimrc. So the problem is probably with that color plugin. I still have no idea how to fix it though.

2
  • 1
    What does :set spellfile? show? When you're in a file with spelling mistakes does ]s move the cursor?
    – B Layer
    May 16, 2020 at 14:19
  • @BLayer :set spellfile? is empty. However ]s does move the cursor to misspelled words. I find and correct misspellings although they are not highlighted. I think the problem must be with solarized.vim, since when I disable it, the highlighting works. But how to fix that color plugin, I have no idea... May 16, 2020 at 14:33

2 Answers 2

1

Since I (or rather the Community Bot) dug this question up after two years, I might as well offer a minimal and elegant answer to have the solarized colorscheme, running in the terminal, with spell checking.

Only one line is needed in addition to the usual solarized setup in .vimrc:

colorscheme solarized
if has('gui_running')
    set background=light
else
    " Tell Vim the terminal cannot draw squiggly underlines,
    " fall back to straight ones
    set t_Cs=
    set background=dark
endif

The effect is that misspelled words are underlined with a straight line.

This answer is condensed from the discussion of the following bugs:

solarized.vim #195 (not to blame)

vim #2424 (the root cause)

2
  • 1
    Some terminals do support the t_Cs sequence (like Alacritty), so unsetting it unconditionally is probably not right.
    – D. Ben Knoble
    Feb 1, 2023 at 14:23
  • @D.BenKnoble that's a good point. Thank you! One would hope that people who don't have this problem would not put random code into their vimrcs ;)
    – Friedrich
    Feb 1, 2023 at 14:31
0

After reading more of the solarized documentation, it's now clear that I should not be using solarized.vim with this terminal emulator. Instead, I should use the emulator's settings to change its color scheme to solarized, and leave vim alone. Now I am only using solarized.vim with gVim and spell checking is working correctly in both versions.

2
  • If this solved your problem, you can accept the answer.
    – D. Ben Knoble
    Jun 10, 2021 at 18:04
  • I really don't think you will get the solarized color scheme to work this way. Take a look at this answer
    – Friedrich
    Jan 31, 2023 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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