Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I see

alt text

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?

share|improve this question
up vote 2 down vote accepted


:set fileformats=unix,dos,mac

Then reread your file with :e.

share|improve this answer
@Greg: Thank you for your answer! – Masi Jul 4 '09 at 11:09
I opened another similar question at… – Masi Jul 4 '09 at 16:51

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 >
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.