![]() I am using Eclipse 3.0.0 and am relatively new at using Eclipse I have used JBuilder and have come to like the ability to add System.out.println('); - by just using a Keyboard shortcut - Ctrl + J However - I have not been able to figure out how to go about the same in Eclipse Its quite irritating to everytime write the same thing again! The list of shortcuts in Eclipse is fairly long yet readily available. In fact starting with Eclipse 3.1 the full list of shortcuts can be displayed from anywhere via Ctrl+Shift+L.Nevertheless, call it information fatigue or simply a matter of style, deserving shortcuts frequently remain overlooked. Below is a list of those shortcuts I find essential. • • • • • When I use Eclipse I try and use shortcuts all the time. They really make me work faster and give me time to focus on getting the code out rather than slowing down to invoke IDE commands with the mouse. Because people work differently and on different things, it’s important to manage keyboard shortcuts to suit the way you work. So it’s good that Eclipse makes it really easy to change shortcuts and also to view shortcuts for the commands you use a lot. I’ll discuss how to change keyboard shortcuts, how to avoid conflicts with existing ones, why it’s a good thing to manage shortcuts and then end off with some examples of common shortcuts that you should add to you arsenal. Advertisement How do you manage keyboard shortcuts The main preference page can be found under Window > Preferences > General > Keys (or faster: Press Ctrl+3, type Keys and press Enter). From here you can see all commands and assign/change their associated keyboard shortcuts. In the video, I’ll show you how to reassign a key. We’ll use this to assign Ctrl+Tab to switch to the next editor. Notes: • You don’t have to copy a command to assign/reassign a shortcut. I just prefer to keep the old shortcut in case someone else wants to take over my keyboard and expects the shortcut to work. • All commands registered with Eclipse are listed on the Keys preference page. Browse through them or search to see if your favourite command is listed. If it doesn’t have a shortcut assigned, then assign one immediately. • The When dropdown on the dialog shows you in which context the command applies (eg. Only when editing Java source). You can assign the same shortcut to two different commands, but if the context differs Eclipse will only execute the one command. I suggest you don’t change the context. • Notice that Eclipse shows you which keys conflict with the selected one if their in the same context. Examples of useful keyboard shortcuts Before continuing the discussion, here are a couple of useful Eclipse keyboard shortcuts you should know. There are way too many shortcuts to list and you’ll come across the more useful ones. Shortcut Action Ctrl+1 list (for resolving errors/warnings) and also Ctrl+Space Display the autocomplete list to select a relevant method/template, etc. Ctrl+3 Open Quick Access which allows you to run commands and navigate views and dialogs by searching for them, similar to Launchy on Windows or QuickSilver on Mac. Ctrl+Shift+R Open any resource in the workspace, eg. XML file, class file, etc. Ctrl+Shift+T Open a Java type, eg. A class or interface. F3 Go to the declaration of the method/class/variable Ctrl+Shift+F Format the selected code. If no code is selected, format the whole class. F11/Ctrl+F11 Debug/run the last launched application (see for more information) Ctrl+Alt+H Display all methods that call a method (call hierarchy) F2 Show JavaDoc for the current element (Shift+F2 shows external JavaDoc) Alt+Up/Down, Alt+Shift+Down, Ctrl+D Move a line up/down, copy a line, delete a line (see for more information) Ctrl+/ Comment/uncomment the current line or selected lines. You can be anywhere in the line, not necessarily at the beginning. You can press Ctrl+Shift+L to get a list of registered keyboard shortcuts in the lower right corner. But for a complete list, I prefer to go to the preference dialog as I can see all commands that are registered, even if they don’t have shortcuts registered. ![]() Advertisement But all the keys are already taken No, they’re not. Firstly, if a key you like is already taken then be creative. Use combos like Ctrl+Alt, Alt+Shift or even Alt+Shift+Ctrl (easier to press then you think). These aren’t used as often as Ctrl or Ctrl+Shift. You can sort by Binding to see which keys are already used. Secondly, Eclipse allows you to assign a sequence of keystrokes to a command. Alt+Shift+X, J (that’s used to run the current class as a Java application) is invoked by pressing Alt+Shift+X, releasing the keys then pressing J.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2019
Categories |