sponsor Vim development Vim logo Vim Book Ad

PickAColor.vim : Inserts and edits color codes using a color name or a graphic color chooser.

 script karma  Rating 14/5, Downloaded by 1276  Comments, bugs, improvements  Vim wiki

created by
Israel Chauca Fuentes
 
script type
utility
 
description
The PickAColor plugin is an attempt to make inserting or modifing colors easier. With it you can use the GTk or Mac OS X color chooser or a color name to insert or modify an existing color code. It borrows heavily from vimscript #3014 and vimscript #2756.

It provides four commands that will insert the corresponding code:
- :PickHEX
- :PickHSL
- :PickRGB
- :PickRAW

You can give a color name as an argument with the command and it will be translated to its corresponding code. You can set which set of color names to use, either web or X11, with the option g:pickacolor_use_web_colors.

Using any of the commands without arguments will open the Mac OS X (if working on a mac) or GTK (if available) color chooser dialog.

When the cursor is on a hexadecimal color code or a color name, it will be replaced with the new color. If you open the color chooser, it will load the current color. This feature can be disabled with g:pickacolor_edit_names and g:pickacolor_edit_hex.

If there is no hexadecimal color code or a color name under the cursor, the clipboard will be read and parsed for one and it will be used for the color chooser dialog.

When you edit or insert a color, the code will be also loaded into the clipboard (under X11 the selection clipboard will be used).

Both features can be disabled with g:pickacolor_set_clipboard and g:pickacolor_get_clipboard.

The color name supported are those listed in the following sources:

Web color names:
  http://www.w3.org/TR/css3-color/#svg-color

X11 color names:
  http://cvsweb.xfree86.org/cvsweb/xc/programs/rgb/rgb.txt?rev=1.2

Read :help PickAColor for more details.
 
install details
requirements:
The script requires Vim 7.2 or later and Python 2.5 or later with the PyGTK module and GTK.

This script is packaged as a vimball. If gnuzip is in your $PATH, simply edit PickAColor.vba.gz in Vim and then source the file; otherwise, decompress the archive first.
e.g.:
        vim PickAColor.vba.gz
        :source %

If you want to remove this plugin, type the following inside Vim:

        :RmVimball PickAColor

If you have GetLatestVimScripts configured, PickAColor will be automatically added the next time you run :GetScripts.
 

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
PickAColor.vba.gz 1.1 2010-03-23 7.0 Israel Chauca Fuentes - Fixed some typos and noisy output. Thanks to Steve
  Huff for pointing this out.
- If GTK is not available and the plug-in is not
  running under Mac OS X, the commands still will work with
  color names.
PickAColor.vba.gz 1.0 2010-03-23 7.0 Israel Chauca Fuentes Initial upload.
ip used for rating: 142.132.191.50

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