Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy and paste in Eclipse adds window newlines at the end of each pasted line

I am using Eclipse (Version: Indigo Service Release 2) on Mac OS X (10.7) with PHP Development Tools and Aptana Studio 3 Plugin.

In Preferences > General > Workspace I have selected: - Text file encoding = UTF-8 - New text file line delimiter = Unix In Preferences > General > Editors > Text Editors I have enabled "Show whitespace characters".

I also use "File > Convert Line Delimiters To > Unix" to regularly change any windows newlines.

Copy-paste of text adds windows newlines (^M) characters at the end of whole lines in the pasted text. This happens despite the fact that the text copied is "clean" of Windows new line characters. This happens for all copy-pasted text (from the same file/editor, or from other sources) if it has at least one whole line in it. I noticed the behavior in git commits.

I believe I have exhausted all possible explanations and did not find anything in my research.

I suspect the Aptana Plugin is the problem because I have a second (separate) installation of Eclipse with all set as above minus the Aptana plugin and never experienced something similar. Nevertheless I can not find anything in Aptana preferences that would look like a potential solution.

Any ideas before I call this a bug?

like image 719
Symvan Avatar asked Mar 23 '12 16:03

Symvan


1 Answers

I had exactly the same annoying problem. After some research and experimentation I think I found the source of the bug and a workaround.

Observations on my set up (Eclipse 3.7.2, PDT 3.0.0, no aptana):

  • it only occurred for me in PHP files inside the <?php ?> delimiters.
  • it only occurred when pasting while the cursor is somewhere on a line with only whitespace. After pasting, all whitespace was removed.
  • When there was a non whitespace character on the line, it did not occur. When pasting in front of the non-whitespace character, the whitespace in front of the character was however removed.

This behavior felt like an issue with automatic indentation handling, so I tried dis-/enabling indentation related options. Disabling the following option fixed it for me:

PHP > Editor > Typing > When pasting adjust indentation

good luck

like image 196
Stefaan Avatar answered Oct 21 '22 15:10

Stefaan