How do I remove extra spaces added to my code by FTP?

This happens repeatedly and is very annoying. I am uploading PHP code to a client server. Several weeks pass. They are asking for changes and I will re-upload the code as they made some changes. However, my code, which was once neat and tidy, the last time I looked at it, now contains extra lines of whitespace. So now that I had two lines of space between some code, we now have 3. Where I had a lot of lines sticking together because they were part of the same loop or such, they are all scattered around now and there is no way to tell them apart.

Is there any program / utility to fix this?

+1


source to share


5 answers


Loading in binary instead of ascii. Ascii mode changes all your line feeds (unix line end character) to carriage return + line feeds (Windows line end characters).



+7


source


You may also have a problem with another editor using tabs when you use spaces (you are using spaces, right?). I've seen similar issues when sharing sources between developers on Linux / OSX and Windows.



+1


source


I bet this is caused by systems trying to convert text files created on a Windows system to files used by a Unix / Linux system (and vice versa).

Windows uses both carriage return and line feed, and I think Unix only uses line feed (or is it a carriage return).

I used Ultra Edit as my main text editor (not that Emacs and vi don't control: o) and it has DOS mode and Unix mode for this sort of thing.

+1


source


Force your client to translate all files in binary mode. This is also useful when you have Unicode text in your files, you never know what assumptions the text modes might use!

+1


source


I am assuming you are developing on a Unix / Max system, but the client is running on a Windows system (or vice versa). I will also assume that you are uploading / downloading your files in binary mode. The window editor probably turns the Unix LF into an LF / CR pair, which your thren editor treats as two new lines. If you upload and download in ASCII mode, the files are automatically converted between the two formats.

+1


source







All Articles