I defined some highlights in the vimrc file and it works well in gvim. However after I mksession
and sourced it back, I found that some (maybe all) of the custom highlights were lost and vim used the default settings of the colorscheme.
The sessionoptions
is blank,buffers,curdir,folds,help,options,tabpages,winsize
.
Snippet from my vimrc file:
let current_color = ""
if has("gui_running")
colorscheme desert
let current_color = "desert"
else
colorscheme torte
let current_color = "torte"
endif
" Section about changing color
if current_color == "desert"
hi LineNr guifg=DarkKhaki
" Or guibg=NavajoWhite1
hi StatusLine guifg=black guibg=LightGoldenrod3
hi PmenuSel guifg=black guibg=LightGoldenrod3
" Or guibg=Plum3
hi Pmenu guifg=black guibg=RosyBrown
hi CursorLine guibg=Grey27
elseif current_color == "torte"
hi CursorLine term=NONE cterm=NONE ctermbg=238
hi Search term=reverse ctermfg=229 ctermbg=136
hi StatusLine ctermfg=16 ctermbg=179 cterm=NONE
hi StatusLineNC ctermfg=244 ctermbg=144 cterm=NONE
hi Comment term=bold ctermfg=74
hi Constant term=underline ctermfg=217
hi LineNr term=underline ctermfg=143
hi Folded ctermfg=220
hi FoldColumn ctermfg=220
hi Special ctermfg=214
hi NonText ctermfg=152 ctermbg=239
hi Visual ctermfg=186 ctermbg=64 cterm=NONE
hi PmenuSel ctermfg=16 ctermbg=179 cterm=NONE
hi Pmenu ctermfg=16 ctermbg=138
hi ColorColumn ctermbg=88
hi WarningMsg ctermfg=202
hi ErrorMsg ctermfg=15 ctermbg=160
hi Error ctermfg=15 ctermbg=160
endif
hi Modifier cterm=inverse ctermfg=118 gui=inverse guifg=#87ff00
hi StatuslineWarning cterm=inverse ctermfg=210 gui=inverse guifg=#ff8787
Any help? Thanks very much!
:hi
(this command will list all the current highlight groups that have attributes set), then look at an element for which the color is not the one you want. For example, let's say you realise that the background color for the StatusLine is the default, not your custom one. Then you could type:verb hi StatusLine
. This command will tell you which file is the last one to have modified the color of the status line. Maybe it will give you a hint of what's going wrong.vim -u NONE -U NONE
and then sourcing manually each file that you want. Besides,vim --startuptime foo bar
will open the file bar and write every file that is sourced during launch inside the file foo.mksession! D:\Session.vim
to manually save a session and then restart gvim andsource D:\Session.vim
to source it back. At first,verb hi StatusLine
showed that it was last modified inD:\Program Files (x86)\Vim\_vimrc
and everything went well. After I saved and restored session, it said that the StatusLine was last modified inD:\Program Files (x86)\Vim\vim74\colors\desert.vim
and the StatusLine was not what I wanted.(Note thatdesert
is my colorscheme).colorscheme
todesert
and then do set custom highlights. I pasted theSession.vim
in Gist. I just tested it in vim and the issue remained. I usevim -S Session.vim --startuptime foo
and found that vim sourced thetorte.vim
before and after sourcing.vimrc
.torte
is my color scheme in vim. I aslo pasted it out in Gist. So there is something wrong in vimrc? It is here.