Tech Journal Back to Tech Journal

Quick tip to use vim to convert from HTML to XHTML

Since all tags in XHTML need to be lower-case, you can fix them like this:

:%s/<\([a-zA-Z]*\)\(\s\|>\)/<\L\1\E\2/g

To fix many of the tag-attributes, you could use:

:%s/\([a-zA-Z]*\)="/\L\1\E="/g
:%s/\([a-zA-Z]*\)='/\L\1\E='/g

That'll lower-case all the words ending with a =" or ='

Last updated on 2005-07-29 14:00:00 -0800, by Shalom Craimer

Back to Tech Journal