`

10 Eclipse Navigation Shortcuts Every Java Programmer Should Know

    博客分类:
  • Java
阅读更多

Man, I’m such an impatient guy. I cringe whenever I see somebody squint and frown, looking for a JSP file in Eclipse by browsing painfully through the gazillion JSPs in multiple folders in the Package Explorer. I squirm whenever I see somebody looking for a Java class by clicking through packages, one by one, backtracking if it’s the wrong package, and so on, until he sees the correct Java class.

I mean, any resource in the workspace is literally seconds away. Ditto to classes (and interfaces, and members, and so on). Why waste time and brain cycles to wade through countless lines in countless files? I thought that every Eclipse user knows this, in fact, if you’re reading this, most probably you already know this too. But thousands of Eclipse JDT users who never bother to read tech blogs in all probability will also never bother to find out what Eclipse can do for them. And it’s a pity, really, because they’re really missing out a lot. So maybe if you know one, you can forward this to them or something. Make them more productive or something, ya know. 30 seconds saved for every file can add up to really a lot!

So without further ado, let’s say you want to:

  • Open any file quickly without browsing for it in the Package ExplorerCtrl + Shift + R. This shortcut opens a dialog box that accepts the name of the file you’re looking for. It even accepts wildcard characters, yo. Typing *-conversion.properties will give you the list of all files that ends with -conversion.properties. So everytime you want to open a file–stop that hand from going to the mouse, and press Ctrl + Shift + R instead!

Opening a resource in Eclipse

  • Open a type (e.g.: a class, an interface) without clicking through interminable list of packagesCtrl + Shift + T. If what you want is a Java type, this shortcut will do the trick. Unlike the previous shortcut, this even works when you don’t have the Java source file in your workspace (e.g.: when you’re opening a type from the JDK).

Opening a type in Eclipse

  • Go directly to a member (method, variable) of a huge class file, especially when a lot of methods are named similarlyCtrl + O. Say, you’re browsing through a file which has 500+ lines of code. How do you look for a method? Don’t use Ctrl + F and then type the method name. Use Ctrl + O, which gives you a list of candidates that match what you’ve typed so far. Select the member you want using the arrow keys, and press Enter. (Alternatively, if you just want to jump from one member to the next (or previous), you can use Ctrl + Shift + ↓ or Ctrl + Shift + ↑, respectively.) UPDATE: As Nick pointed out in the comments section, pressing Ctrl + O again shows the inherited members. Thanks Nick! :)

Browse Member

ctrl_o_2.jpg

  • Go to line number N in the source fileCtrl + L, enter line number. Of course if the stack trace is in the Eclipse console, you can just click the hyperlink. But if it’s in a log file or something, just use this shortcut to go to the line in a jiffy.

Go to a line number

  • Go to the last edit locationCtrl + Q for . If you have a big file, it’s annoying to jump from one location in line 1000+ to 2000+ only to realize after looking at line 2017 that you’ve made a mistake in that location near line 1000+ just now. This shortcut brings you right to where you last edited a file. Very handy in a big file. Gone are the days of “let’s see… where did I edit it again… nope, nope… ah there it is”. (This even works when you’re already looking at a different file.)
  • Go to a supertype/subtypeCtrl + T. Before I found this, if I want to go to the superclass of a class, I’d go the the very top of the file, hover my mouse over its superclass, hold Ctrl, and click. Disgusting. Now I just press Ctrl + T and I get this dialog below, which toggles between supertypes and subtypes when you press Ctrl + T again.

Subtype hierarchy view

Supertype hierarchy view

  • Go to other open editorsCtrl + E. I know you can cycle through the editors using Ctrl + F6 as well, but I prefer Ctrl + E because Ctrl + F6 has this annoying behaviour of requiring you to keep the Ctrl key down, and the distance between Ctrl and F6 is so far I have to twist my left hand to do that. Just press Ctrl + E, and either use the arrow buttons, or type the name of the file you’re editing.

Open editor

  • Move to one problem (i.e.: error, warning) to the next (or previous) in a fileCtrl + . for next, and Ctrl + ,for previous problem. No need to lift your hands off the keyboard to click on that red or yellow stripe.
  • Hop back and forth through the files you have visitedAlt + ← and Alt + →, respectively. I have to admit I don’t find myself using these two often, though.
  • Go to a type declarationF3. Alternatively, you can hold Ctrl down and click the hyperlinkedvariable or class or whatever it is the declaration of which you want to see–but why lift your hand off the keyboard? Just press F3 and Eclipse will bring you to the declaration of whatever is at the cursor at that moment.

OK, that’s it for this post. There are tons of other Eclipse shortcuts not covered by this article. To see the whole list, just open up your Eclipse (I’m assuming Eclipse 3.2 here–in older or more recent versions this may differ slightly), go to Help → Help Contents → Java Development User Guide → Reference → Menus and Actions. The whole motherload is there, from generating comments, correcting indentations, surrounding with, and so on.

The point I’m trying to get across is: Eclipse has a LOT of shortcuts to make things real easy for you. Java (or heck, any software) development is hard. We shouldn’t make it harder on ourselves by fighting our tools! Let our tools help us as much as possible, so we all can go back on the dot and spend more time with our family, lovers, or whatever it is we want to spend more time on. There’s no honour in working hard inefficiently. Only disgrace.

 

分享到:
评论

相关推荐

    net.sourceforge.texlipse_1.0.0_src.zip_eclipse navigation_eclips

    Texlipse is a plugin that adds Latex editing support for the popular Eclipse Java IDE. Key features include: syntax highlight, command completion, bibliography completion, outline navigation and ...

    Navigation

    根据在网上下载的一个横向的二级菜单,修改成自己想要的菜导航条。供大家参考一下,有什么写得不足的地方还请赐教。我的qq号是342951527.

    Eclipse中文使用教程

    5 .10 Java 表示式及变更某些值 6 .重构 (Refactoring ) 6 .1重新命名 6 .2撷取 ( Extracting ) 6 .3列入 ( Inlining ) 6 .4变更方法签章 ( Signature ) 6 .5移动 Java 元素 (Moving Java Elements ) 6 .6自行封装...

    Bash-Terminal-Keyboard-Shortcuts-for-Navigation.pdf

    Bash-Terminal-Keyboard-Shortcuts-for-Navigation.pdf

    eclipse ide 变得如此热门

    我观察过无数的同事,当试图在eclipse的navigation面板里找一个类的时候,不假思索的按下“ctrl + shift + t”(打开型别(open type))。其实,只要有意识的投入一点点时间,你也会不在笨手笨脚的,而成为热键...

    ROS与navigation教程.pdf

     ROS 与 navigation 教程-目录  ROS 与 navigation 教程-设置机器人使用 TF  ROS 与 navigation 教程-基本导航调试指南  ROS 与 navigation 教程-安装和配置导航包  ROS 与 navigation 教程-结合 RVIZ 与...

    Introduction to Modern Navigation Systems

    What is navigation anyway? It is the ability to set the course of a ship to move between two desired locations. To do that the navigator must be able to know his location and set the velocity vector ...

    Eclipse – 整合开发工具

    要訣和技巧(Tips and Tricks) 266 7.1編輯程式檔(Editing Source) 266 7.2搜尋(Searching) 271 7.3程式碼導覽和讀取(Code navigation and reading) 273 7.4 Java視圖(Java views) 277 7.5...

    [Navigation] Navigation for ASP.NET Web Forms

    Navigation for ASP.NET Web Forms manages movement and data passing between ASPX pages in a unit-testable manner. There is no client-side logic, so it works in all browsers, and no server-side cache, ...

    Outdoor_Navigation_Pro

    Outdoor Navigation 是一款非常实用的户外导航软件。软件会根据用户当前的位置在地图上进行定位,并且在界面上显示用户位置的经纬度以及方向。另外有一点功能非常强大,就是软件在定位的同时会自动将您平时所拍的...

    eclipse 中文版教程

    13 Eclipse 版本介绍 10 14 跨语言、跨平台 11 2 Eclipse Platform 13 21 概观 13 22 架构 13 23 项目与资料夹 14 24 平台核心 14 25 工作区(workspace) 15 26 工作台(workbench) 15 261 视图(View) 16 ...

    Android Material Bottom Navigation使用教程

    今年三月Google已经将Bottom Navigation加入到Material中,但是目前还没有这方面的使用教程,所以本demo介绍使用LuseenBottomNavigation。

    android navigation

    android navigation

    Flash navigation: Happy New Year 2011

    Happy New Year 2011 is a Free Flash Navigation of New Year, and you can Custom the Links by xml files. This Flash navigation has Gallery automatically display, beautiful snowflake pattern, and you can...

    Applied Mathematics in Integrated Navigation Systems 3rd

    The subject of integrated navigation systems covered in this book is designed for those directly involved with the design, integration, and test and evaluation of navigation systems. It is assumed ...

    Global Navigation Satellite Systems, Inertial Navigation, and Integration.zip

    Global Navigation Satellite Systems, Inertial Navigation, and Integration

    ICAO-Annex-10-Volume-1-Radio-Navigation-Aids

    ICAO-Annex-10-Volume-1-Radio-Navigation-Aids

    自定义tabbar+navigation

    自定义tabbar+navigation

Global site tag (gtag.js) - Google Analytics