1

I just added a few things to my colorscheme.vim which is sourced from my .vimrc. In fact, it is the last line in the .vimrc.1

source ~/.vim/colorscheme.vim

Oddly, now most of it doesn't apply, yet some of it obviously does. If I manually :source ~/.vim/colorscheme.vim it works, and so the only solution I've found is to add a keybinding for that. I.e., now everytime I start the editor I have to manually load the colorscheme.

Here's colorscheme.vim. The stuff I added was mostly for Diff but a few other things got tweaked. Loaded manually, it all seems to work.

hi ColorColumn guibg=Black guifg=#dbdbdb ctermbg=black ctermfg=yellow
hi Comment ctermbg=gray ctermfg=darkblue guibg=#dbbdbd guifg=#000088
hi Conditional cterm=bold ctermfg=yellow gui=bold guifg=#ffff00
hi Constant ctermfg=brown guifg=#ff8800
hi Cursor guibg=#ff0000 guifg=#ffff00
hi Directory ctermfg=gray
hi DiffAdd guibg=#000044 guifg=#ffff00
hi DiffChange guibg=#000044 guifg=#aaaaaa
hi DiffDelete guibg=#000044 guifg=#008888
hi DiffText guibg=#884400 guifg=#ff8800
hi ErrorMsg ctermbg=red ctermfg=cyan cterm=bold guibg=#880000 guifg=#ffffff gui=bold
hi Folded guibg=#00ff00 guifg=#3300aa ctermbg=blue ctermfg=green
hi Identifier ctermfg=darkgreen gui=none guifg=#449944
hi LineNr ctermbg=black ctermfg=darkblue guibg=#111111 guifg=#444444
hi NonText ctermfg=red guifg=#ff8800
hi Normal guibg=#222228 guifg=#dbdbdb
hi Number cterm=underline ctermfg=green gui=underline guifg=#00ff00
hi PreProc cterm=bold guifg=#cccc88 
hi Repeat cterm=bold ctermfg=cyan gui=bold guifg=#00ffff
hi StatusLine cterm=bold ctermfg=green ctermbg=darkmagenta guibg=#aa00aa guifg=#00ff00
hi StatusLineNC ctermfg=7 ctermbg=black
hi Special ctermfg=magenta gui=bold guifg=#ff0088 guibg=#303030
hi SpecialKey ctermfg=darkblue guifg=#111111
hi SpellBad ctermbg=gray ctermfg=darkred
hi Statement ctermfg=gray guifg=#448888 
hi Type ctermfg=darkcyan guifg=#dd88dd gui=italic

if has("gui_running")
        set guioptions -=r
        set guioptions +=l
        set guioptions -=T
endif

A weird thing about "some of it" working is that it includes, e.g., SpellBad, which is near the end. So it is not flaking out at some point, it is just ignoring or overriding most of the other stuff.

This applies to both console vim and gvim.


1. Note that there were no changes made to .vimrc, although since then I've tried moving that line to the top, etc., but this did not make any difference.

4
  • How are you sourcing it in .vimrc? What is the output of :scriptnames before you manually load it?
    – muru
    Commented Feb 13, 2016 at 20:40
  • I've edited that in at the top. As indicated, nothing in vimrc was edited when I did this. The output of scriptnames includes it in order with other sourced scripts and does not change before or after sourcing it manually.
    – goldilocks
    Commented Feb 13, 2016 at 20:49
  • 3
    :help hi-normal-cterm recommends setting the colors for Normal first, before setting any other colors. My first suggestion is to move the hi Normal ... line to the top of the hi list. Next, I would set your colorscheme from your ~/.vimrc by executing colorscheme colorscheme rather than by sourcing the file so as to pick up any other steps Vim thinks is necessary when setting a colorscheme. Not that other approaches won't work, but if you're having trouble, the closer your attempt is to the "standard" solution, the better chance you will have finding someone who can spot the problem.
    – garyjohn
    Commented Feb 13, 2016 at 23:24
  • 1
    @garyjohn When I added those new lines I alphabetized everything -- something I had forgotten but your explanation reminded me. However, moving "Normal" to the top didn't fix anything. What did is sourcing it via colorscheme (regardless of where Normal is). I fear my use of the term "color scheme" in the title and the fact that I called the sourced file colorscheme.vim may have caused some confusion -- the actual command is something I had never heard of. My .vimrc goes back more than a decade and I've just occasionally moved parts of it out to other files for sourcing.
    – goldilocks
    Commented Feb 13, 2016 at 23:38

1 Answer 1

2
  1. Your "colorscheme" is missing too many things to be called a "colorscheme". Here is a fixed version:

    " 'strawberry.vim' -- Vim color scheme.
    " Author:       ...
    " Description:  ...
    
    hi clear
    
    if exists("syntax_on")
        syntax reset
    endif
    
    let colors_name = "strawberry"
    
    hi Normal guibg=#222228 guifg=#dbdbdb
    
    set background=dark
    
    hi ColorColumn guibg=Black guifg=#dbdbdb ctermbg=black ctermfg=yellow
    hi Comment ctermbg=gray ctermfg=darkblue guibg=#dbbdbd guifg=#000088
    hi Conditional cterm=bold ctermfg=yellow gui=bold guifg=#ffff00
    hi Constant ctermfg=brown guifg=#ff8800
    hi Cursor guibg=#ff0000 guifg=#ffff00
    hi Directory ctermfg=gray
    hi DiffAdd guibg=#000044 guifg=#ffff00
    hi DiffChange guibg=#000044 guifg=#aaaaaa
    hi DiffDelete guibg=#000044 guifg=#008888
    hi DiffText guibg=#884400 guifg=#ff8800
    hi ErrorMsg ctermbg=red ctermfg=cyan cterm=bold guibg=#880000 guifg=#ffffff gui=bold
    hi Folded guibg=#00ff00 guifg=#3300aa ctermbg=blue ctermfg=green
    hi Identifier ctermfg=darkgreen gui=none guifg=#449944
    hi LineNr ctermbg=black ctermfg=darkblue guibg=#111111 guifg=#444444
    hi NonText ctermfg=red guifg=#ff8800
    hi Number cterm=underline ctermfg=green gui=underline guifg=#00ff00
    hi PreProc cterm=bold guifg=#cccc88
    hi Repeat cterm=bold ctermfg=cyan gui=bold guifg=#00ffff
    hi StatusLine cterm=bold ctermfg=green ctermbg=darkmagenta guibg=#aa00aa guifg=#00ff00
    hi StatusLineNC ctermfg=7 ctermbg=black
    hi Special ctermfg=magenta gui=bold guifg=#ff0088 guibg=#303030
    hi SpecialKey ctermfg=darkblue guifg=#111111
    hi SpellBad ctermbg=gray ctermfg=darkred
    hi Statement ctermfg=gray guifg=#448888
    hi Type ctermfg=darkcyan guifg=#dd88dd gui=italic
    
  2. Put your colorscheme in ~/.vim/colors/:

    ~/.vim/colors/strawberry.vim
    
  3. Add this line to your vimrc in order to enable your colorscheme:

    colorscheme strawberry
    
12
  • 4
    Everything you are doing is wrong and can't work. My answer shows you how to do it right.
    – romainl
    Commented Feb 13, 2016 at 22:12
  • 2
    Your answer EXPLAINS NOTHING. I am not interested in this: en.wikipedia.org/wiki/Cargo_cult_programming "Cut n' paste and trust me" approach. However, after a little experimentation I did garner something from this which did solve the problem, so if you would care to explain that (since I think you know what it is), then I'll accept the answer too. If not, I'll add my own explanation in an answer and leave it at that. (BTW, "can't work" obviously isn't true, because I've used it this way for years, but that is not the issue)
    – goldilocks
    Commented Feb 13, 2016 at 22:16
  • 3
    Everything is explained in various places of Vim's doc, which you are supposed to read; I'd suggest :help :syn-default-override. Your "colorscheme" is not a proper colorscheme so I show you how to make it one. That's a solution to your problem #1. You put it in the wrong place and I show you where to put it, that's the solution to your problem #2. You don't call it the right way and i show you how to call it correctly, that's a solution to your problem #3. But I'd say your problem #0 is simply not reading the manual and following your intuition anyway. For this I have no solution.
    – romainl
    Commented Feb 14, 2016 at 9:57
  • 4
    @romainl can you list a few of the missing things required for a colourscheme? Say, 5 of them? That would go a long way in improving this answer.
    – muru
    Commented Feb 14, 2016 at 11:18
  • 2
    @JohnSchmitt When outside a function, the default scope is global.
    – Rich
    Commented Nov 16, 2022 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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