`

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.

 

分享到:
评论

相关推荐

    Eclipse-Shortcuts

    #### 文件导航(File Navigation) **快捷键**: `Ctrl+Shift+R` **描述**: 打开资源。此快捷键用于快速访问项目中的任何资源,包括文件、目录等。 **快捷键**: `Ctrl+E` **描述**: 从所有打开的文件列表中打开一个...

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

    eclipse中文帮助文档

    Eclipse是一款广泛使用的开源集成开发环境(IDE),尤其在Java编程领域中占据着重要的地位。这份"eclipse中文帮助文档"提供了丰富的图文信息,旨在帮助用户更好地理解和掌握Eclipse的各项功能和操作。以下是对其中...

    eclipse下的js插件

    在IT行业中,Eclipse是一款广泛使用的开源集成开发环境(IDE),尤其在Java开发领域享有盛誉。然而,Eclipse的功能并不仅限于Java,它也支持多种其他编程语言,包括JavaScript(JS)。针对JS开发,Eclipse提供了丰富...

    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自行封装...

    从零开始学Eclipse(光盘源码)

    Eclipse是一款广泛应用于Java开发的集成开发环境(IDE),它以其强大的功能、高度的可扩展性和灵活性深受开发者喜爱。从零开始学Eclipse意味着我们将深入理解这个工具的基础知识,逐步掌握其核心特性和使用技巧。 ...

    eclipse_多语言编辑插件

    10. **Debugging**: Eclipse的调试工具不仅支持单步执行、设置断点,还支持多线程调试和远程调试,使得问题排查更加高效。 11. **Plugins and Extensions**: Eclipse的开放架构允许开发者根据需求自定义和扩展IDE...

    Eclipse3.4_SSH2框架搭建

    在构建Eclipse3.4_SSH2框架的过程中,我们涉及到了一套完整的开发环境与一系列关键技术组件,这包括了Eclipse3.4作为集成开发环境、Tomcat-5.5.28作为应用服务器、Mysql-5.1.49作为数据库系统,以及一个由Struts2.0...

    Android Material Bottom Navigation使用教程

    Material Design的组件库包含了许多元素,如按钮、输入框、导航抽屉等,而Bottom Navigation是其中之一。本教程将详细介绍如何在Android项目中使用Material Design的Bottom Navigation。 Bottom Navigation是一种...

    Eclipse Workbench教程(英文)

    10. **调试(Debugging)**:Eclipse Workbench的调试功能强大,支持多线程调试,允许设置断点、查看变量值、单步执行代码,帮助开发者定位和解决问题。 11. **版本控制系统集成**:Eclipse与Git、SVN等版本控制...

    eclipse ide 变得如此热门

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

    EclipseShortcuts Eclipse常用快捷键

    本文将详细介绍 Eclipse 中的一些常用快捷键,帮助 Java 开发者更好地提升自己的开发速度与质量。 #### 二、Eclipse 快捷键概览 Eclipse 是一款功能强大的开源 IDE,主要用于 Java 开发,但也可通过插件支持其他...

    Eclipse_界面中英文对照

    10. Window—>Preferences(窗口—>首选项):这是 Eclipse 中的首选项菜单,提供了许多个性化设置功能。 * General(常规):设置 Eclipse 的常规选项。 * Ant(蚂蚁):设置 Ant 的选项。 * Java:设置 Java 的...

    BottomNavigationView去除菜单项动画效果代码

    在Android开发中,BottomNavigationView(底部导航视图)是一个常用组件,用于在多个视图间进行切换。在设计用户界面时,我们有时需要对它的默认行为进行自定义,比如在这个场景下,我们要去除 BottomNavigationView...

    eclipse juno 汉化包(8.6号更新)

    Eclipse Juno汉化包是针对Eclipse IDE的中文语言包,主要目的是为用户提供中文界面,便于中国开发者在使用Eclipse Juno版本时能够更加顺畅地进行开发工作。Eclipse Juno是Eclipse IDE的第四个主要版本,发布于2012年...

    BottomNavigationView实现底部导航

    在Android应用开发中,`BottomNavigationView` 是一个非常重要的组件,它用于实现底部导航功能,让用户可以在多个主要视图之间轻松切换。这个组件通常包含3到5个图标和相应的文字标签,代表应用的主要功能模块。在...

    Android Training学习笔记——Navigation 参考源码(NavigationView版)

    在Android应用开发中,`NavigationView`是一个非常重要的组件,它通常位于 DrawerLayout 侧滑菜单内,用于展示应用的主要导航选项。本篇文章将深入探讨`NavigationView`与`Navigation`组件的使用,结合Android ...

    ROS与navigation教程.pdf

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

Global site tag (gtag.js) - Google Analytics