This is a simple question :
Is there any automatic indentation alignment on Eclipse PDT when you do a c开发者_Python百科opy-paste ?
Because it doesn't work on my installation (raw copy-paste), but maybe this is because I use tabs instead of spaces, so I want to know if it will work if I switch to spaces.
Thanks
Actually, such a function exists now for eclipse CDT. In preferences : C++ -> Editor -> Typing, "when pasting", "adjust indentation".
Perhaps it is the same for PDT ?
I don't know specifically about PDT, but normally you can indent code with Ctrl + i
, and format code with Ctrl + Shift + f
(under Preferences -> Java -> Code Style -> Formatter
you can specify how the formatter should work).
You can even select multiple files in the navigator and select Source -> Format
to format several files then.
Tony Vermeiren had a suggestion that worked for me (from https://bugs.eclipse.org/bugs/show_bug.cgi?id=351771#c17)
open workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.php.ui.prefs
add "smartPaste=false" at the end
save & restart eclipse
A similar idea to Davids is the use of Save actions: in the Preferences selecting Java/Editor/Save actions you can define an action to format the java code files during saves. It would solve the paste format problems during the save.
If you manage codes with different coding standards, where this formatting might have problems, define multiple formats, on a per-project basis (using the Project properties window).
Ok then I guess the answer is : no, this functionnality doesn't exists yet. I've moved to PhpStorm and I'm more than happy.
TLDR: uncheck "C/C++->Editor->Typing->Adjust indentation"
Explanation:
When i copy paste the following:
And "C/C++->Editor->Typing->Adjust indentation" checked
The result is that the second line has unwanted indentation:
To fix this just uncheck "C/C++->Editor->Typing->Adjust indentation"
精彩评论