Vim: Set Color/Theme based off time of day

Something like the following should do the trick:

if strftime("%H") < 12
  set background=light
else
  set background=dark
endif

Obviously you should choose the hour based on your needs


Try the werewolf.vim plugin:

Werewolf changes your vim colorscheme automatically based on the time of day, allowing you to use a light theme during the day but "transform" to a dark theme once the sun goes down.

If you use often different color schemes, you can set several pairs of light/dark color schemes, and it will automatically switch to the matching scheme.


This is not strictly a Vim answer but you could try to install f.lux which adjusts your monitor colours to the time of the day.

Here is a demo. It has a warm yellowish glow during the day, and blueish one during the night.

Disclaimer : I have not tried it myself (but I am tempted).

Tags:

Vim