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

情到浓时终转凉″ 提交于 2019-12-03 10:19:56

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/9842597/copy-and-paste-in-eclipse-adds-window-newlines-at-the-end-of-each-pasted-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!