Replacing lowercase CSS hex code with uppercase in vim
Changes #5e342f -> #5E342F or #efe -> #EFE
/#[0-9a-f]\{6}\|#[0-9a-f]\{3}/\U&/g
Breaking it down
Everything starts with #
[0-9a-f]
is the range of characters
\{6}
means that there needs to be exactly 6 occurrences of the pattern
NOTE: We're being more selective first since if the string isn't 6 characters long, it may only be 3.
\|
is the pivot on the search it's VIM regex for OR.
Then #
, [0-9a-f]
as before.
\{3}
catches those weird cases where the color code is only 3 characters long and repeats (e.g. #3f3, or #fff).
\U
Changes all the alphabetic characters to uppercase.
&
Applies the \U
to the whole pattern.
Written by Mike Nielson
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#