Monday, April 30, 2012

Re: Colorschemes and split window

It seems that I have found the solution (after many many hours of trying :-( )

I created the function below.
The function must do this (and seems to do it):

a) when there is only 1 window:
check if filetype is "vim" --> Dark_ColorScheme
if filetype is not "vim" --> Light_ColorScheme
b) when there is a split window:
check if exist split window colorscheme variable (g:splitcolor)
if yes, colorscheme of splitwindow = g:splitcolor

when leaving split window:
keep the value of the current color in g:splitcolor

Can anyone tell me if I made a mistake and if the function can be simplified?

function SetColors()
if winnr('$') > 1
if exists('g:splitcolor')
exe 'colors '.g:splitcolor
else
exe 'colors Light_ColorScheme'
endif
elseif winnr('$') == 1 && &ft == 'vim'
exe 'colors Dark_ColorScheme'
elseif winnr('$') == 1 && &ft != 'vim'
exe 'colors Light_ColorScheme'
endif
endfunction
function KeepColors()
if winnr('$') > 1
let g:splitcolor = g:colors_name
endif
endfunction
augroup filetype_colorscheme
au BufEnter * call SetColors()
au BufLeave * call KeepColors()
augroup END

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: