Getting rid of ^M newline characters in Notepad++

Today I was modifying someone else’s file when I noticed that when I uploaded it to the server it displayed horribly. All whitespace was gone, and in the place of newlines was ^M characters. Here’s a snapshot of how the file looked when I uploaded.

If I viewed it with ‘more filename.php’ I didn’t see the ^M but it looked as if the whole file was on one line, and some characters had been replaced by {. Strange.

It does not affect the server’s ability to run the file, but it does make maintenance a nightmare if you ever have to edit the file in the future.

I had been using Notepad++ (notepad plus plus) to edit it, and I had never had this problem with any of my files. Turned out the file had originally been made on a Mac, which caused these weird characters to show up (sometimes it happens on Windows too).

Luckily there’s an easy fix. With the file open in Notepad++, simply go to the Edit menu -> EOL Conversion -> Windows. It might also work if you choose Unix too. Then save the file, re-upload and you’re golden!

Hope that helps!


Posted

in

,

by

Tags:

Comments

15 responses to “Getting rid of ^M newline characters in Notepad++”

  1. sudhakar Avatar
    sudhakar

    This helped me and I really appreciate this.. well done

  2. Zina Ramirez Avatar

    Thanks for posting this. I struggled with searching for a fix to very cryptic parse errors (unexpected T_STRING, unexpected $end) until I found this. Most advice online says it must be a missing curly bracket.

  3. Englebert Avatar
    Englebert

    Thanks dude

  4. Trey Avatar
    Trey

    helped me too… Thanks for the quick and helpful instructions

  5. JOhn Avatar
    JOhn

    Thank you!

  6. prakash Avatar
    prakash

    thanks lot..this really helped.

  7. Cam Avatar
    Cam

    Thanks a lot!!!

  8. Duginthamud Avatar
    Duginthamud

    Thanks! I knew it was there but lost it.

  9. Anonymous Avatar
    Anonymous

    thanks!!

  10. senthil Avatar
    senthil

    Thank you!! this helped me:)

  11. uri Avatar
    uri

    Thanks!!

  12. Jain Avatar
    Jain

    thank you 🙂

  13. Umang Gujrati Avatar
    Umang Gujrati

    Thank you. This was really helpful !!

  14. Cristian T Avatar
    Cristian T

    Cool, its workin

Leave a Reply to Jain Cancel reply

Your email address will not be published. Required fields are marked *