+1  A: 

you can do this as a macro, something like this in your .vimrc (i'll let you fill in the rest of the entities ;-) ):

let @a=':%s/á/\á/g^M:%s/é/\é/g^M:%s/í/\í/g^M ... '

note that ^M is a special character entered using Ctrl+V, Ctrl+M.

scomar
+1  A: 

Perl is better for this sort of things. Paste your file into vim and run this:

:%!perl -p -i -e 'BEGIN { use Encode; } $_=Encode::decode_utf8($_) unless Encode::is_utf8($_); $_=Encode::encode("ascii", $_, Encode::FB_HTMLCREF);'

Or even better:

%!perl -p -i -e 'BEGIN { use HTML::Entities; use Encode; } $_=Encode::decode_utf8($_) unless Encode::is_utf8($_); $_=Encode::encode("ascii", $_, sub{HTML::Entities::encode_entities(chr shift)});'

(HTML::Entities is a part of HTML::Parser on my system)

ZyX
+2  A: 

I would recommend Tim Pope's unimpaired plugin. It provides commands to encode and decode html entities, using the mappings: [x and ]x respectively.

nelstrom