Question

My files are on a remote Ubuntu Linux server. When I download the files and edit it in either the WinSCP text editor or Notepad++, the file end-of-line style changes to Windows. So when I resave the file back to Ubuntu the lines are off and SVN Diff thinks every line has changed.

FYI, I edit the file by double clicking the file in WinSCP. This program launches the file in the editor. Every time I save, the file is automatically copied back to the Linux server.

How do I prevent the end-of-line style issue?

Was it helpful?

Solution 2

I wasn't able to figure out why I had the whitespace issue but I was able to figure out how to ignore whitespaces.

You can use:

svn diff -x'-uw --ignore-eol-style'

This worked well enough.

OTHER TIPS

Does this thread help? More precisely this part:

From this, it seems to me that you have forced WinSCP to use text mode transfer, which imply the unix->dos conversion. Just force the binary mode to avoid the conversion.

You need to use the unix line format. To set this, go to Settings>Preferences and select the "New Documents/Default Directory" tab. Find "Format" in the "New Document" controls and select "Unix". This will ensure any new document has the correct format. I have used this with a remote linux server and have not seen a problem.

Typically, the returned file would be created with a temporary name and the changes written to it. The original file would then be removed and the new file renamed to take its place. This would make the the returned file a "new" document so this preference setting should give the correct format.

I use Notepand2 and WinSCP to edit files on Windows and server is on Linux.

In my case the problem was with WinSCP connection itself.

I clicked "Edit" before the connection and then "Advanced" there was option for End-of-line characters. Changing it solved the problem in my case.

Option on the screen is already the one that worked. Ealier there was "LF" only.

enter image description here

The simple and appropriate fix to that issue can be done by going into the configuration of your external editor in WinSCP

In: View > Preferences > Editors

Select your external editor and click Edit ...

Then, uncheck: Force text transfer mode for files edited in external editor

If you use text/ascii mode transfer with WinSCP, it would convert the end-of-line style back to Unix on upload.

So I guess the problem might be that your file actually has Windows end-of-line style initially. On download, nothing changes, but on upload, it gets converted to Unix style.

Either fix your file to use the Unix style as it should (if that's the case) or use the binary transfer mode.

Not only you need to configure the binary transfer mode for WinSCP in general (what is the default in recent versions of WinSCP), but you also need to make sure that the preference option Force text transfer mode for files edited in external editor for your external editor (Notepad++) is off:
https://winscp.net/eng/docs/ui_editor_preferences

Note that this option is not available for WinSCP internal editor. With it files are always transferred in the text/ascii mode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top