Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic indentation on Eclipse PDT when copy-pasting

This is a simple question :

Is there any automatic indentation alignment on Eclipse PDT when you do a copy-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

like image 464
Matthieu Napoli Avatar asked Mar 18 '10 13:03

Matthieu Napoli


3 Answers

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 ?

like image 117
Offirmo Avatar answered Nov 16 '22 02:11

Offirmo


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.

like image 23
David Sauter Avatar answered Nov 16 '22 02:11

David Sauter


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

like image 37
Greg Avatar answered Nov 16 '22 03:11

Greg