Vim Tips Wiki
(Remove html character entities)
(adjust previous/next navigation + minor manual clean)
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
{{TipImported
 
{{TipImported
 
|id=662
 
|id=662
|previous=661
+
|previous=660
|next=663
+
|next=667
|created=February 25, 2004
+
|created=2004
 
|complexity=basic
 
|complexity=basic
 
|author=James Childers
 
|author=James Childers
|version=5.7
+
|version=6.0
 
|rating=14/8
 
|rating=14/8
 
|category1=HTML
 
|category1=HTML
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

Latest revision as of 05:24, 11 August 2011

Tip 662 Printable Monobook Previous Next

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


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