Vim Tips Wiki
Register
Advertisement

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created August 10, 2007 · complexity intermediate · author Alex Jakushev · version 6.0

One part of converting from HTML to XHTML is changing all the tags to lowercase. If you open your HTML file in Vim, this task may be done with this piece of Vim magic:

:%s/<\/\?\zs\(\a\+\)\ze[ >]/\L\1/g

Note that this will change tag names only. To change tag attributes to lowercase as well (multiple attributes supported), use this command:

:%s/\(<[^>]*\)\@<=\<\(\a*\)\ze=['"]/\L\2/g

Comments

This should work as well:

%s/<\(.[^>]*\)>/<\L\1>/g

Advertisement