I've changed my eclipse formatter to using Spaces Only
for indentation and an 'Indentation size' (and 'Tab size') of 2.
After making these changes, and no other changes from the built-in formatter, I now have a problem when pasting comments.
Instead of being indented correctly, for example:
private String str1;
// Correctly indented comment
private String str2;
Now my comments are pasted in with no heading space and the space between the backslash and the comment text is removed, like so:
private String str1;
//Incorrectly indented comment
private String str2;
Is there some way to fix this behavior?
I have the Adjust Indentation
property turned on under Java -> Editor -> Typing -> When pasting
.
Installation details (from About):
Eclipse SDK
Version: 4.2.2
Build id: M20130204-1200
I think I could reproduce the problem that you are facing.
But it happens only if I copy from a source that is not indented. Is this your case?
Although I don’t have an explanation of why this happen, I think the fastest way to fix the indentation is to reapply the eclipse formatter to your code via Ctrl+A and then Ctrl+I.
The space between the backslash and the comment text still will not appear, but I hope it is not a big deal for you.