sponsor Vim development Vim logo Vim Book Ad

CSSMinister : Converts colors in CSS stylesheets from one format to another

 script karma  Rating 19/8, Downloaded by 901  Comments, bugs, improvements  Vim wiki

created by
Lou Gonzalez
 
script type
utility
 
description
CSSMinister provides functions and mappings that convert any hexadecimal, keyword, RGB(A) or HSL(A) color values from one format to another.  The functions fall into two categories:  1) those that change the next matching color only, and 2) those that change all colors matching the requested format in a range or in the entire buffer.

Functions that change formats one color at a time include:

  :ToHex
  :ToRGB
  :ToRGBA
  :ToHSL
  :ToHSLA

Functions that change all colors matching the requested color format in a range or in the entire buffer:

  :ToHexAll <format>
  :ToRGBAll <format>
  :ToRGBAAll <format>
  :ToHSLAll <format>
  :ToHSLAAll <format>

Where <format> is the color format you're converting from.

As of v1.0.0, the above commands replace the old key mappings as a less obtrusive solution for converting between different color formats. Some key mappings remain for those that prefer them:

  <leader>x - convert to hex
  <leader>r - convert to rgb
  <leader>h - convert to hsl
  <leader>ra - convert to rgba
  <leader>ha - convert to hsla

This script was tested with CSS, Sass and Less stylesheets.  However, it should work anywhere CSS color values are used.
 
install details
If you're using vundle, add this line to your .vimrc:

  Bundle "CSSMinister"

Using pathogen? Unzip the contents into your bundle/ directory. Otherwise, unzip in your ~/.vim folder and run :helptags ~/.vim/doc.
 

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
CSSMinister.zip 1.0.0 2012-02-05 7.0 Lou Gonzalez * Added extended color keywords
* Conversions between HSLA and RGBA formats
* Visual mode conversions
* Handle zero-padded color values in RGB(A) and HSL(A) colors
* Replaced old mappings with less obstructive commands
* Added config options
CSSMinister.zip 0.2.1 2010-03-21 7.0 Lou Gonzalez Convert from any HTML4 color keyword to any of the supported formats.
CSSMinister.zip 0.1.0 2010-03-07 7.0 Lou Gonzalez Initial upload
ip used for rating: 3.145.2.184

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.
   
Vim at Github