Brad Mace
Brad Mace

Reputation: 27886

Jump to beginning/end of block in Eclipse

First off, I'm not looking for CTRL+SHIFT+P, but something a little more flexible. Is there any way to jump from anywhere inside a block to the beginning or end of that block?

Upvotes: 15

Views: 13506

Answers (5)

Pedro Garre
Pedro Garre

Reputation: 11

If you have the Outline window visible, you will have the current function highlighted. Click on it and you will go to the function declaration. Works in PHP.

Upvotes: 1

wile the coyote
wile the coyote

Reputation: 61

I am addressing the situation when one wants to find which method does a certain line of code belong to (this is practical for large method blocks, when you have reached a certain line via Search for a keyword within the workspace). Of course, this answers a particular sub-case, as methods are blocks of code, too, but not all blocks of code are methods.

One can gradually press Shift+Alt+Up Arrow, as pointed in an above answer, and will eventually have highlighted the entire body of the enclosing method.

However, when highlighting a piece of code, in the Outline view, it's enclosing method is already highlighted, and clicking on it will bring the focus on the beginning of the method, in the Editor.

Upvotes: 0

Jayram Kumar
Jayram Kumar

Reputation: 712

In eclipse on mac, you can go to the top of the file editor using command+. And you can go to the bottom of the file editor using command+.

Upvotes: 0

Paresh Pednekar
Paresh Pednekar

Reputation: 181

CTRL + SHIFT + UP works and takes you to the beginning of the function. If you repeat it again takes you to the next function in the upward direction. CTRL + SHIFT + DOWN takes you to function names in DOWNWARD direction.

I tried in Version: Mars.1 Release (4.5.1)

Upvotes: 18

jmiserez
jmiserez

Reputation: 3109

I'm afraid the command you are looking for does not exist in vanilla Eclipse.

You can try Shift+Alt+↑ , which will select the enclosing element. It should eventually select to whole block. ←  then moves the cursor to the beginning, →  moves it to the end.

But it really isn't any faster than:

  1. End to jump to the end of the line
  2. Ctrl+Shift+P to go to end of the block
  3. Ctrl+Shift+P again to go to start of the block

If your code is somewhat reasonably formatted (i.e. not everything on one line), this should always work.

Also check the list of possible shortcuts in Preferences->General->Keys, there isn't one that does what you want.

Upvotes: 12

Related Questions