Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can sees that when I use mksession it writes file to save session. The file looks ok and session is loading ok. But It change my colorsheme when I load the session whith so. After session is opened the color scheme is another. What it can be? Why I cannot restore my session?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

@itun The default behavior for VIM sessions is that it doesn't save off the colorscheme. While I'm sure there is a good reason for doing this, I'm not sure what it is.

I have also run into the same situation, and wrote a couple of VIM functions and a VIM command to get the behavior you are talking about (really only needs to save off the :colorscheme colors_name).


" ===========================================================================
function! Mksession(...) " {{{
" Intercept the mksession built-in, so that we can append the current
" colorscheme to the setup as well.
" ---------------------------------------------------------------------------
"  call Dfunc("Mksession()")

" if argc() > 2 " echohl ErrorMsg " echo "Command takes only 2 arguments, extra arguments ignored!" " echohl None " endif

" call Decho("a:0=<".a:0.">") " call Decho("a:1=<".a:1.">") " call Decho("a:2=<".a:2.">") " If no overwrite flag is supplied, assume no overwrite if a:1 == "" let l:overwrite = 0 elseif a:1 == "!" let l:overwrite = 1 endif

" If no session name is supplied, default to Session.vim in the current working directory if !exists("a:2") || a:2 == "" " if !exists("l:sessionname") || l:sessionname == "" let l:sessionname = "Session.vim" else let l:sessionname = a:2 endif

" call Decho("sessionname=<".l:sessionname.">") " call Decho("overwrite=<".l:overwrite.">")

if l:overwrite == 0 exe "mksession ".l:sessionname else exe "mksession! ".l:sessionname endif silent exe '!echo colorscheme '.g:colors_name.' >> '.l:sessionname

" call Dret("Mksession") endfunction " Nodiff com! -nargs=+ -bang -complete=command Mks call Mksession("",) cmap mks Mks cmap mksession Mks " }}}

This will create a VIM User command to wrap the built-in one (:Mks ), and also will add command-mode abbreviations to expand out the built-in command to use the new User Command version.

Hope that helps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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