Search code examples
vim

Vim: Set Color/Theme based off time of day


I have one of those super glossy monitors, so during the day I can see my own reflection better than my code on Dark themes. So I thought it'd be great if I could have a simple if switch in my vimrc to set either a dark theme or a light theme based on the time of day.

Alas, I don't know enough about vimrc syntax and googling came up short.

Anyone wanna take a crack at this?


Solution

  • 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