I see
alt text http://files.getdropbox.com/u/175564/bug-enc.png
where all contents is in one line.
It seems that this is the reason of bad encoding. I can see the characters ^M
.
How can you get the encoding right in Vim?
I see
alt text http://files.getdropbox.com/u/175564/bug-enc.png
where all contents is in one line.
It seems that this is the reason of bad encoding. I can see the characters ^M
.
How can you get the encoding right in Vim?
Try:
:set fileformats=unix,dos,mac
Then reread your file with :e
.
These are "line breaks", or newlines.
From your screenshot it seems the file uses Mac-style line breaks, which are a single carriage return (0x0D
, in the screenshot shown as ^M
).
Windows (and most of the Internet protocols) use both carriage return and line feed (0x0D 0x0A
), and Unix uses a single line feed (0x0A
) to separate lines. Macs used to only use carriage returns (now Unix-style is common on MacOS X too).
In vi/vim, try this command to make it recognize the file:
:set ff=mac
You can try using this command to convert the file to Windows-style line breaks:
sed "s/\x0D/\x0D\x0A/g" yourfile.html > yourfile.new.html