The Support OS X’s Color picker thread on the MacVim mailinglist made me hack on a little vim script that lets you select a color in OS X’s color picker and automatically insert it at the current postition in the buffer.
This can for example be useful for web developers who are editing their CSS files with Vim or similar tasks.
Installation
You can grab the script here
To install the script, as usual put it into
~/.vim/plugins
Usage
"to insert hex values at the current position :ColorHEX "to insert RGB values at the current position :ColorRGB
Update (2010-03-13)
Uploaded new version 0.2 that keeps the focus on MacVim or the Terminal and checks for OS X. Also renamed the script to colorx.vim
The script is now also hosted at Vim scripts
Update (2010-10-01)
Updated to version 0.3. New feature: pick up the hex color code under the cursor.
This is SO cool! Thanks for sharing!
Thanks, glad you like it
I’ve also just uploaded a small update that keeps the focus on MacVim or the Terminal, for a better workflow.
Can you either email me, or post detailed directions on how to use this utility? I put it in .vim/plugins, but have no idea how to run it. I’ve tried using it at the : prompt in vi and all I get is command not found. I’m a newbie, so please help me out.
Ohhh, maybe you know analog on Linux?
Thanks for this. For me it’s another peice in the puzzle of being productive in Vim again.
It would be great if the colourpicker could pick up the current colour from the cursor ala the behaviour in TextMate.
Cheers,
Sean.
Nice.
I’ll have to assist Sean concerning the ability to pick up the color under the cursor and display that on the Mac Colors window.
That would improve the script enormously !
I’ve found some time to hack a bit on this script and it should pick up hex colors under the cursor now.
Thanks everyone for suggesting this feature!
You can grab the updated file above or at vim.org