Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change new line character when editing existing files in eclipse?

Tags:

eclipse

To change the new line character for "New text file line delimiter" one would go to

Window -> Preferences -> General

Then change the "New text file line delimeter" to Windows, Unix or Max OS9.

I would like to know how to change the default line delimiter when editing existing files.

My co-worker uses a Mac and commits a Java class. I then check it out and add more code. When I do a "git diff" my changes have meta-characters (^M). I presume they are carriage-return characters.

What setting can I use in Eclipse to always use Unix style new line characters not just for new text files?

like image 441
RogerRoger Avatar asked Oct 20 '25 23:10

RogerRoger


2 Answers

To convert the file that's open/exists:

File -> Convert Line Delimiters To -> Unix

like image 199
Ankur Raiyani Avatar answered Oct 26 '25 06:10

Ankur Raiyani


Try Preferences->General->Workspace.

Set Text file encoding to UTF-8. Set line delimiter to Unix.

You could also configure GIT to not show the carriage return characters when doing a diff.

Add whitespace = cr-at-eol under the core section.

This article explains how to configure GIT for checking out, committing and Windows/Unix styles.

like image 36
km1 Avatar answered Oct 26 '25 07:10

km1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!