Vim Tips Wiki
(Remove html character entities)
(Adjust previous/next navigation + minor manual clean)
Line 2: Line 2:
 
{{TipImported
 
{{TipImported
 
|id=662
 
|id=662
|previous=661
+
|previous=660
 
|next=663
 
|next=663
|created=February 25, 2004
+
|created=2004
 
|complexity=basic
 
|complexity=basic
 
|author=James Childers
 
|author=James Childers
Line 13: Line 13:
 
}}
 
}}
 
This is a simple regex that can be used to search an HTML file and replace all unquoted attributes with their quoted version.
 
This is a simple regex that can be used to search an HTML file and replace all unquoted attributes with their quoted version.
 
 
<pre>
 
<pre>
 
map <F9> :%s/\([^&^?]\)\(\<[[:alnum:]-]\{-}\)=\([[:alnum:]-#%]\+\)/\1\2="\3"/g<CR>
 
map <F9> :%s/\([^&^?]\)\(\<[[:alnum:]-]\{-}\)=\([[:alnum:]-#%]\+\)/\1\2="\3"/g<CR>
Line 20: Line 19:
 
==Comments==
 
==Comments==
 
I use this regex and abbreviate it to "reg1".
 
I use this regex and abbreviate it to "reg1".
 
 
<pre>
 
<pre>
 
cabbrev reg1 %s/=\([^"][^> ]\{0,40\}\)/="\1"/gc
 
cabbrev reg1 %s/=\([^"][^> ]\{0,40\}\)/="\1"/gc

Revision as of 02:26, 30 March 2010

Tip 662 Printable Monobook Previous Next

created 2004 · complexity basic · author James Childers · version 5.7


This is a simple regex that can be used to search an HTML file and replace all unquoted attributes with their quoted version.

map <F9> :%s/\([^&^?]\)\(\<[[:alnum:]-]\{-}\)=\([[:alnum:]-#%]\+\)/\1\2="\3"/g<CR>

Comments

I use this regex and abbreviate it to "reg1".

cabbrev reg1 %s/=\([^"][^> ]\{0,40\}\)/="\1"/gc