简体   繁体   中英

Jump to beginning/end of block in Eclipse

First off, I'm , 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?

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)

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 (ie 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.

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.

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 + .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM