On Monday, April 30, 2012 8:15:26 AM UTC-5, rameo wrote:
> 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
Looks like it should do what you want, just fine. A minor note, you don't need the exe if you're providing the colorscheme name literally, e.g. "exe 'colors Dark_ColorScheme'" could be just "colors Dark_ColorScheme", but that's not really an important detail; it should work fine as-is.
--
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
Monday, April 30, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment