1

Given this ~/.vimrc

syntax on
colo pablo
set cul
hi CursorLine cterm=bold ctermbg=NONE ctermfg=NONE gui=bold guibg=NONE guifg=NONE
hi String ctermfg=red

Do the following:

  • open a file, possibly containing some string (so a double quoted sting in Vim or on C++, for instance);
  • observerve that, expectedly,
    • the coloring of the strings is red, not the one dictated by pablo
    • the current line is highlighted with bold text rather than with the true underline dictated by pablo
  • run :mksession
  • close the file
  • reopen the session with vim -S Session.vim
  • observe that, unexpectedly to me, the file opens just like the 4th and 5th line of the ~/.vimrc were not there.

In the following screencast you can see the effect on the colors of the strings (not on the underline, unfortunately, because of how asciinema works, I guess).

asciicast

  • @JakeGrossman, I see it is related, but maybe a more specific answer to how the colorscheme and the vimrc interact with vim -S Session.vim would be better. – Enrico Oct 2 at 7:23
  • @Enrico so what does :verbose :hi String return? – Christian Brabandt Oct 2 at 11:33
  • 2
    I’m not convinced it’s all that different, and the solution is the same: put the highlight commands in an autocommand. – D. Ben Knoble Oct 2 at 12:38
  • @ChristianBrabandt, String xxx ctermfg=9 when opening without -S, String xxx links to Constant when opening with -S. – Enrico Oct 2 at 14:20
  • 1
    The autocmd needs to be defined before you call colorscheme – D. Ben Knoble Oct 2 at 15:31