开发者

Code navigation in Eclipse

开发者 https://www.devze.com 2023-02-16 13:04 出处:网络
I find it difficult to navigate through code for a big project involving many classes, XML files, SQL files etc.

I find it difficult to navigate through code for a big project involving many classes, XML files, SQL files etc.

I know Shi开发者_运维百科ft-Ctrl-R to open resources, but thats where my little knowledge ends. How can I easily navigate through a hell of Java and non-Java files in Eclipse with just keyboard. Most of you gurus already will have a list of favorite code navigation shortcuts/tips, I suppose.

Please share.

Thanks!


Try these shortcuts:

Ctrl + Shift + R for opening any resources

Ctrl + E for switching between open windows

Ctrl + Shift + T for opening loaded classes

Ctrl + T for opening type hierarchy

Ctrl + O for viewing all the methods in a class / interface. Pressing this again shows you all the superclass methods too.

Ctrl + F11 to run a previously run class.

Alt + Shift + K and then J for running a class as Java Application.

Holding Ctrl when clicking on a method / class / interface opens it.

Also check out the Java Browsing perspective.


F3 : Go to the declaration / definition of method / variable

Cmd + [ : Go back

Cmd + ] : Go Forward

Cmd + 1 : Quick Fix

Cmd + T : Shows Class Hierarchy

Cmd + Shift + o : Fix Missing Imports

Cmd + / : Comment / Uncomment code

Cmd + Shift + / : Comment/ Uncomment with block comment

Cmd + L : Go to Line

Cmd + Shift + F : Auto Formatting

Cmd + D : Delete Line

Ctrl + Q : Go to To Last Edited Place

Cmd + Shift + G : Search the Workspace for references to the selected method or variable

Cmd + Shift + R: Open any file quickly without browsing for it in the Package Explorer:

Cmd + Shift + T: Open a type (e.g.: a class, an interface) . Unlike the previous shortcut, this even works when you don’t have the Java source file in your workspace

Cmd+Shift + P : Find Closing Brace.

Fn + Option + Del : Delete next word

Option + Del : Delete previous word

Shift + Fn + Cmd + Del : Delete to the end of the line

Shift + Cmd + Del: Delete to the start of the line

Shift + Cmd + L : List all Eclipse Keyboard Shortcuts

Cmd + K : Find Next

Shift + Cmd + K : Find previous

Cmd + Enter : Insert line above

Shift + Cmd + Enter : Insert a line below

Alt + Shift + R : Renames variables / methods / classes, renaming the class files if necessary. Also fixes all references


Alt + Left Arraow -- Goes back (just like in a browser)

Alt + Right Arraow -- Goes forward

Ctrl + Q -- Goes to the last edited line of code

Also a usefeul tip when looking for classes is to press Ctrl + Shift + T and partially type the name of the class/interface/enum that you look for. For instance, if you were to look for a class named StringParserHelper, you could type SPH, or StrPH, or String*Hel, or *ParH. Exercise with the combinations. This will help you allot.

Ctrl + . Goes to next problem (compilation error or warning) Ctrl + , Goes to previous problem (compilation error or warning)

There are many useful shortcuts. You can look at them by pressing Ctrl + Shift + L. Press it twice and you will be edit the keyboard shortcuts.


Navigating code with Eclipse, using the keyboard? Here are some shortcuts I use with high frecuency:

  • F3: while on a class name, a method name, or a variable reference, it opens the selected element declaration.
  • F4: Opens the type hierarchy view for the selected element (a class, or method...)
  • Shift+Ctrl+T: search and open a Java Type (note that it won't search on JSPs, XML files, etc. only will search the classes declared)
  • Ctrl+F6: Opens a dropdown with the list of open files (so you can change from one to another).
  • Ctrl+F7: Dropdown with the available views. It allows you to switch from code editor to the Navigator view (so you can open other files)

There are lot more, but I use thess few continually


To add up a few

Ctrl Shift O - To organize imports

Ctrl 1 - To get suggestions on a specific line

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号