Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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've googled all around and found tons of weird solutions to ^M problem, but couldn't find one and simple: how could I just open any file, like in Notepad++ and work on it? I don't want to mess with LF and CR stuff, anyway git will correct it on push. Is there a "stupid" solution for this issue? One little thing, I'm forced to work in the World Evil OS right now, so the solution should work for it.

share|improve this question
How does Notepad++ handle mixed line endings? – Evan Teitelman Jun 18 '13 at 10:46
:set binary


$ vim -b file

This will leave all line endings as-is, and lines are separated by single <NL> characters. I don't recommend using it, but you've explicitly asked for a "stupid solution".

share|improve this answer

I advise you to fix your line endings.

To convert the file to \n line endings:


To convert the file to \r\n line endings (untested):


You can make vim perform one of these operations automatically when you open a file:

autocmd BufRead, * normal :%s/\r$

You could also use the dos2unix and unix2dos utilites.

share|improve this answer

I use vim on cygwin myself - and if the file is labeled correctly as a dos file, it does not show the ^M characters, and I even have the the info line at the bottom set to tell me if it is a dos or unix type file. Some files may have windows line endings, but still show up as unix - if I run dos2unix on those files it is then fixed, and vim correctly labels it and hides ^M the next time I open that file.

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.