views:

1063

answers:

12

Hi !

(Yes, this is a quite opened and general and subjective question -- it's by design, cause I want tips you think are great !)

I'm using Eclipse PDT 2.1 to work in PHP, either for small and/or big projects -- I've been doing so for quite some times, now, actually (since before 1.0 stable, if I remember well)...

I was wondering if any of you did know "tips" to be more efficient.

Let met explain more in details : I know about things like plugins like Aptana (better editor for JS/CSS), Subversive (for SVN access), RSE, Filesync, integrating Xdebug's debugger, ...

What I mean by "tips" is more some little things you discovered one day and since use all the time -- and allow you to be more efficient in your PHP projects.

Some examples of "tips" that come to my mind, and that already know and use :

  • ctrl+space to open the list of suggestions for functions / variables names
  • ctrl+shift+R (navigate > open resource) to open a popup which show only files which names contain what you type ; ie, quick opening of files
    • this one might be the perfect example : I know this one is not often known by coworkers and they find it as useful as I do ; so, I guess there might be lots of other things like this one I don't know myself ^^
  • ctrl+M to switch to full-screen view for the editor (instead of double-click on tabs bar)
  • shift+F2 while on a function name, to open it's page if the PHP manual in a browser

Attention Mac Users use Command instead Control.

I guess you get the point ; but I'm really open to any suggestion (be it eclipse-related in general, of more PHP/PDT-specific) that can help be be more efficient :-)

Anyway, thanks in advance for your help !

+10  A: 

A general thing that is very usefull but nobody knows about in Eclipse is moving lines. If you want to move a whole line up or down in your source code just press alt + up arrow or alt + down arrow. If you want to move more then one line you have to mark them and then do the same thing. This is very useful for moving debugging outputs around. Or sorting files or quickly move a line in or out a block.

Janusz
First answer, first thing I learn ! I've tried, and this is really nice : no more "selecting, ctrl+X, moving up, hitting enter to insert an blank line, ctrl+v, ..." ! I'll definitly use this one ! Thanks !
Pascal MARTIN
thanks for the tip, and it works in all eclipse editors too, not just PHP
Newtopian
This is a good one, I use it all the time.
Josiah
Nice tip, thanks ! I'm about to use it all the time...
Timothée Martin
+5  A: 

When you press Ctrl+Alt+Up you will duplicate your currently selected line.

Pressing Ctrl+D deletes an entire line.

Josiah
A: 

(shameless marketing ahead)

We have a new product coming up (currently in public beta) which complements PDT 2.1 called nWire for PHP. It is a code exploration plugin which allows you to quickly navigate, search and visualize your code, accelerating the development process.

zvikico
-1 for being off-topic even though the product looks good
Josiah
shameless indeed
middus
+3  A: 

Ctrl+Shift+p to move from a bracket to another.
Ctrl+o to open the list of the methods.
Ctrl+e to open the list of tabs.

MaoTseTongue
+2  A: 

Indenting selected block by pressing tab, both shifts+tab for indenting the selected block to the left.

f3 on a method or variable takes you to that place, eg $this->method makes the editor go to that method. + ctrl+alt+left/right to go back to where the cursor was before

ctrl+f6 to switch editors

ctrl+f7 to switch between editor/navigator/outline etc

koen
wow the editor switching is great
Janusz
+1  A: 
  • CTRL+MAJ+F, Wich will call the autoformater method. Once configured, it work like a charm.
  • CTRL+J, when being in a method, generate automatically the php docbook
  • CTRL+MAJ+C comment / uncomment the active line/selection
  • CTRL+ALT+A Shows VCS annotations for the current file
Alexis Métaireau
+1  A: 

ctrl+space let you also access to templates. You can create your own templates, with variables, in the preferences of the PHP plugin.

This one is a feature I have to learn to use more : this template-stuff really looks nice !
Pascal MARTIN
+1  A: 

CTRL+SHIFT+I indent the selected lines CTRL+SHIFT+/ comment / uncomment the selected lines

A: 

Just as a an update, here are a couple more :

  • When you are in the editor, select some portion of text (like a function name or whatever)
    • then, Ctrl + K will get you to next occurence of that portion of text in the current file
    • Ctrl + Shift + K will get you to the previous one
  • When using the search dialog box (you can get it by Ctrl + F) :
    • press Alt + n to go to the next occurence of the term you are searching for
    • if you check the "incremental" checkbox, it'll start searching as you type

(This way, I'll be able to find those some future day -- and it might be usefull to other people too)

Pascal MARTIN
+1  A: 

As a newcomer to Eclipse I have found Ctrl + Shift + L to be very helpful: it will open up a list of all hot-keys and their associated actions.

Shift + Alt + A will turn on Column Select, which allows you to choose a column of text instead of a line. Very useful when editing lists in html, or modifying comments in php. From what I understand this is only in the Eclipse version 3.5+ (please correct me if I'm wrong.)

somethingkindawierd
I didn't know there was a column-mode in Eclipse *(it's one of the things I rarely use, but which really help, sometimes)* ; thanks !
Pascal MARTIN
A: 

Cmd+F3 to go to the method declaration (works in most contexts)

I installed the GoToFile Plugin (its super old, but still works) and bound it to a key combo. I got used to this feature from TextMate. It recognizes camel case and avoids using the Project Explorer, which I find very tedious.

pocketfullofcheese
A: 

Coming from TextMate on the Mac I have been looking for these!

  • Ctrl+Shft+Y To Lower Case
  • Ctrl+Shft+X To Upper Case
somethingkindawierd