When you run colorscheme default it resets background to default value which is in your case incorrectly detected to be light. So I think if you change the order of commands to: if g:usercolour == 0 colorscheme default set background=dark ... Then it should work for you.

Only top voted, non community-wiki answers of a minimum length are eligible