Vim Tips Wiki

Translate HTML entity numbers to text

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 217 Printable Monobook Previous Next

created 2002 · complexity intermediate · author Larry Clapp · version 6.0

I found a website ( that likes to obfuscate some help file web pages using &#nnn; instead of normal ascii. If you load the source with Vim (in Opera you can just designate Vim as your source viewing program), you can :source the following code to make it readable.

let n = 32
while n < 127
  if n == 38
    silent! exec '%s/&/\&/g'
  elseif n == 47
    silent! exec '%s///\//g'
    silent! exec '%s/&#' . n . ';/' . nr2char(n) . '/g'
  let n = n + 1

Disclaimer: I hacked this together in about 10 minutes. It worked suitably for one web site. Your mileage may vary.



[Author implies there are some bugs in above.]

I'll upload the code as a script instead. See script#223.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki