Fix double line breaks in PHP after download
- by Seth Carstens
- March 12, 2012
There has been a problem with developing from a Windows machine and using and modifying the files from a Unix or Linux machine. Well, the problem is that they don’t detect end of line styles in the same way. In this article we are going to explain how to fix 2 problems associated with this issue.
Problem #1: How should I Fix “svn: Inconsistent line ending style”?
The solution is simple. You will need the free software Notepad++. Once you have opened your file with this program:
“Ctrl+Shift+A” on the keyboard and finally go to file menu “Edit”->”EOL Conversion”->”Windows format”
Problem #2: How do I remove double line breaks that appear my my files after downloading (syncing) files with my server?
After years of just dealing with seeing the double line breaks and leaving them be, we finally got fed up with them. Typically removing them causes some heartache because doing so in most programs removes any tabbing you were using for source formatting.
This can also occur, we believe, if you use the WordPress theme/plugin upload tool. Because it uses Linux/Unix commands to decompress and extract the data line by line, it also adds in Unix style line endings which causes the “double line break” affect.
Thankfully, with Notepad++ you can now fix your problem with a “find and replace”.
- Open your File (or files, as you can fix multiple files at once).
- Go to file menu “Search” -> “Replace”.
- In the find box look for the following: \n\r
*if that doesn’t work try: \r\n (depends on which way the file was converted on the server vs the client)
- In the replace box, make sure its completely empty.
- You may optionally click find a few times just to make sure its only selecting the “doubled” line breaks. But not to worry, if you replace all and don’t like the results, just don’t save any of the files.
- Click the button that says “Replace All in All Open Files”.
- Check your files for consistency and then save close and update them on your server.
You must be logged in to post a comment.