Chris Stryczynski

Software Developer / Consultant

Dynamic theme color for Vim based on time of day

Posted on: 02/08/2020

I prefer using a light colored theme during the day, and a dark colored theme during the night. If you think about it, it more closely resembles your natural environment right? It complements a blue light filter as well.

This is simply done with Vim using a timer:

function DynamicColorThemeSwitch()
  let l:hour = strftime('%H')

  if (l:hour < 15) && (l:hour > 3)
    set background=light
    set background=dark

"run every 10 mins repeatedly
call timer_start(1000 * 60 * 10, function('s:set_bg'), {'repeat': -1})
call DynamicColorThemeSwitch()

Based off with help from:

If you have any suggestions for similar things like these, please let me know in the comments, I’d love to hear about them!


No comments, yet!

Submit a comment