$ cyanpencil's blog - posts - about - contact

Rotate vim colorscheme between day and night automatically

It happens quite often that I work on my laptop outside during the day. My all-time favourite colorcheme, alduin, gets absolutely killed by sunlight. For this reason, I have to sometimes switch to a light colorscheme.

ouch, my eyes.
Left for the night, right for the day.figcaption> </center> </figure> Switching manually colorscheme gets tedious after the second time. But it turns out that making it automatic is really simple, just add those lines to your `.vimrc`: ```vimscript if strftime('%H') % 19 > 7 set background=light colo lightning else set background=dark colo alduin endif ``` For now, I'm using [lightning](https://github.com/wimstefan/Lightning) as the light themed colorscheme, but I'm not really a fan of it. If you know about one as cool as alduin, let me know via email or Telegram. I really need it. _Note: if you use [vim plug]() to manage your colorschemes, make sure to put the `colorscheme` command after the call to `plug#end()`, otherwise you will just end up with the default colorscheme._