Vim Tips Wiki
(New page: <!-- --> {{Tip |title=Changing all HTML tags to lowercase |created=2007.08.10 |complexity=intermediate |author=Alex Jakushev |version=6.0 |text= <!-- multiline text with wiki markup ...)
 
No edit summary
Line 19: Line 19:
 
}}
 
}}
   
  +
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:
To convert all html tags and their attributes to html, you can use vim s///g commands described here:
 
   
  +
:%s/<\/\?\zs\(\a\+\)\ze[ >]/\L\1/g
http://31plus.blogspot.com/2007/08/changing-all-html-tags-to-lowercase.html
 
  +
  +
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
  +
  +
 
Originally published at http://31plus.blogspot.com/2007/08/changing-all-html-tags-to-lowercase.html
   
 
== Comments ==
 
== Comments ==

Revision as of 14:41, 14 August 2007


Tip: Changing all HTML tags to lowercase

Created: 2007.08.10 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


Originally published at http://31plus.blogspot.com/2007/08/changing-all-html-tags-to-lowercase.html

Comments