History
Article Edit this page Discussion

Quote unquoted HTML attributes

From Vim Tips Wiki

Jump to: navigation, search

Tip 662 Previous Next Created: February 25, 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>

[edit] Comments

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

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

Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto Wiki
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Quote unquoted HTML attributes"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation