Created
December 23, 2011 14:07
-
-
Save kylewest/1514301 to your computer and use it in GitHub Desktop.
replace all 3-character HEX color codes with 6-character codes in vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this will replace all 3-character HEX color codes with 6-character codes in vim. | |
%s/#\([0-9A-Fa-f]\)\([0-9A-Fa-f]\)\([0-9A-Fa-f]\)\([0-9A-Fa-f]\)\@!/#\1\1\2\2\3\3/g | |
1-- | |
2--------------------------------------------- | |
3-------------- | |
4---------------- | |
5- | |
1. substitution. | |
2. # followed by valid hex digit. \( \) is used to group the matches. | |
3. zero width preceding match to only match #111, not #111111. ':help @!' for details. | |
4. substitution. double each of the matched groups. | |
5. global match. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment