sponsor Vim development Vim logo Vim Book Ad

Sunset : Automatically set background on local sunrise/sunset time.

 script karma  Rating 4/4, Downloaded by 1311  Comments, bugs, improvements  Vim wiki

created by
Alastair Touw
script type

Sunset automatically sets 'background' when the sun rises and sets, and also when you start Vim. When the sun is up, or rises, it'll 'set background=light'. When the sun is down, or sets, it'll 'set background=dark'.

Sunset can also change your 'colorscheme', your Powerline (https://github.com/Lokaltog/vim-powerline) theme, or anything else you can think of. See ‘Sunset_daytime_callback()' and ‘Sunset_nighttime_callback()' in the documentation for details.

So as not to interrupt you, Sunset waits for four seconds (on the CursorHold event) after you've pressed a key or left insert mode before changing the background. If you change your background during the day or night, it'll respect that.


If you feel that Sunset can be improved, pull requests and issues are appreciated and humbly requested, on Github at: http://github.com/amdt/sunset


Vim compiled with +float support. Use ':version' to check if this feature is available in your build.

Requires a system with 'strftime()', with the following format options:
- %j returns the current day of the year.
- %H returns the current hour of the day in 24-hour time.
- %M returns the current minute of the hour.

A colorscheme with both light and dark variants, such as Solarized (http://github.com/altercation/vim-colors-solarized) or Hemisu (http://github.com/noahfrederick/Hemisu).
install details
Installation is provided here with a Vimball. See ':help vimball' for installation instructions. If you prefer a package manager or manual install, please see the previously mentioned Github page.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
sunset-3.1.0.vmb 3.1.0 2015-02-28 7.4 Alastair Touw * Made 'g:sunset_utc_offset' optional
(thanks to 'andreax79': https://github.com/amdt/sunset/pull/11)
* Fixed an issue that caused a 'E122' error with the 'restore_cpoptions' function
sunset-3.0.0.vmb 3.0.0 2015-02-22 7.4 Alastair Touw * Fixed an issue where 'cpoptions' may not be restored when the script finishes early
* Updated the function names for the 'Sunset_daytime_callback()' and 'Sunset_nighttime_callback()' callbacks to match changes to the VimL interpreter
sunset-2.0.1.vmb 2.0.1 2014-05-08 7.3 Alastair Touw Fixed an issue where versions of Vim greater than 7.4.260 would not allow this script to run. (https://github.com/amdt/sunset/issues/8)
sunset-2.0.0.vmb 2.0.0 2013-01-12 7.3 Alastair Touw - Sunset now switches your background (or calls your callbacks) mid-way
  through Civil Twilight time.
- *Note:* Sunset 2.0.0 breaks compatibility with previous versions of
  Sunset for users of the `sunset_callback()` callback.
  'sunset_daytime_callback()' and 'sunset_nighttime_callback()' are
sunset-1.2.1.vmb 1.2.1 2012-11-22 7.3 Alastair Touw - Fix table of contents numbering in documentation.
sunset-1.2.0.vmb 1.2.0 2012-11-05 7.3 Alastair Touw - GetLatestVimScripts-compatible.
- New behaviour with 'sunset_daytime_callback()' and 'sunset_nighttime_callback()'.
- sunset_callback() has been deprecated and will be removed in the next release.
sunset-1.1.0.vmb 1.1.0 2012-10-28 7.3 Alastair Touw Added 'sunset_callback()'.
sunset-1.0.3.vmb 1.0.3 2012-10-20 7.3 Alastair Touw Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
OSDN.net Logo