Eclipse: Can You Hit A KeyBinding To Find The Command It Is Bound To? - eclipse

I'm new to Eclipse. Is it possible in Eclipse to hit a keybinding and find the name of the command it is bound too?
For example, pressing Ctrl+Shift+R and have something like "open-dialog" come up in a list telling me that Ctrl+Shift+R is bound to the command "open-dialog".

Unfortunately, Eclipse doesn't make this easy. (Related note: IntelliJ IDEA does.) There are a few things that might help you out, though:
In the Eclipse settings for key bindings, you could do "Export to CSV". Then you can search that document for key combinations.
Also in the Eclipse settings for key bindings, you can sort the "Binding" column. The list is unwieldy to scroll through, but the ordering of multi-key combinations seems to be well defined so you could eventually find the key combination you're looking for.
If you want to look up a common command without going into the settings, you can assign a keyboard shortcut to "Show Key Assist". You can't sort the list by key combination, but it's at least a relatively short list to look through.

Windows > Preferences > General > Keys
You can TYPE ( not press ) the name of the keys, it will sort the list by the name of the keys

Going by the original wording,
pressing Ctrl+Shift+R and
have something like "open-dialog" come up
it sounds like the Show key binding when command is invoked -> Through keyboard option in the Keys preference page would at least partially do what you're looking for:
This will bring up a toast-like overlay each time you press a key combination that's associated with a command. It will show the command name and a more detailed command explanation, if available.
However, the overlay will only display for a few seconds and then disappear, i.e. an onlooker might miss it if they are distracted by other activities on the screen. I don't think that there is a way to display this information "in a list", i.e. in a more permanent fashion, but I think that this would be a great feature to help developers learn new keyboard shortcuts in a pair programming environment.

Related

Defining properties (docstrings) for Emacs key bindings

I [currently] don't use the menu feature for want of screen real estate, so it's possible the answer lies there.
Is there any way to associate a docstring with a keybinding such that it'll show up in the C-c C-h (or related) help displays? Right now all I get is either Prefix Command or the name of the function/lambda to which the key is bound. I'd like to have something about the purpose of the prefixed keymap for the former, and explanatory text for the more obscure functions for the latter.
Yes, I know that clicking on the function name will bring up a help window with details; I'm just looking for a one-liner property that can be shown in the original *Help* pane without disrupting the screen layout with new panes.
I suspect the answer is 'no,' but it seems a fairly obvious feature..
Thanks!

Eclipse - multiline comment with asterisks doesn't work

I'm not able to use ani shortcuts for using comments with asterisk. Every key combination doesn't work. I tried with CTRL+/, CTRL+SHIFT+/, CTRL+C; all of these have the same output, i.e. a simple comment with // on every line. Other shortcuts like CTRL+\, CTRL+SHIFT+\ or CTRL+SHIFT+F doesn't work at all.
So, how can I have this shortcut?
These are the Comments options
Open Window>Preferences>General>Keys>type "add block comment" in the search box, you should see:
the type "remove block comment"
These settings are by default, but if the shortcut is not working on your machine, you must be missing these bindings, To create them, you need to mark the command "Add Block Comment", then click inside the "Binding" field and press CTRL+SHIFT+/, then press Apply. The same is for uncommenting.
I have a similar problem to the one you have: the / shortcut seems to trigger a folding operation (at least in the Java editor) that does not appear in the keys preferences table.
Modifying the key in the keys preferences table seems to work fine: setting the binding to Shift+Ctrl+Q for the "Add Block Comment" command sets the expected block comment.
The reason is clear to me: the Shift+Ctrl+/ binding is very difficult to reproduce in a Linux environment because Eclipse makes a clear difference Numpad_Divide and the '/'. The Normal '/' strike is being modified by the shift key (French keyboard).

What's the trick to write code faster in Eclipse?

I know there is a trick that when you type quickly code in Eclipse, you can hit some secret keys and it will auto-complete the missing parts. Who knows them?
example: I have someVeryLongVariablesWhichIWantToTypeFast and I start typing someVeryLongVa but nothing happens. Only when I type method names a yellow box appears that wants to help me.
Ctrl + Space is the autocomplete shortcut
All shortcuts you can find under Window -> Preferences -> General -> Keys
As mentioned the command is Ctrl+Space to auto complete.
You can speed it up using camelCase...so in your example:
someVeryLongVariablesWhichIWantToTypeFast
you could start typing sVL then Ctrl+Space should auto complete or list all variables that match.
CamelCase also works for specify classes, searching for classes etc.
Others I like/use:
type sysCtrl+Space to get System.out.println statement (or err)
type foreCtrl+Space after an array/list line to foreach it
Click on an argument to a method and Ctrl+1 to create a field for it and assign it, great for constructors
Ctrl+1 on any local variable to convert to field, split declaration, or inline it
if you have
object.method().method2().method3()
selecting object.method() and type Ctrl+1 to assign to a field or local variable, then you get
Object objLocal=object.method()
objLocal.method2().method3()
//Can now select objLocal.method2() and do the same again
My favourites:
Ctrl + Space - auto complete
Ctrl + 1 - show quick fix options when you are over an error / warning
Shift + Ctrl + L - list short cuts
One trick that I love in Eclipse for Java is writing backwards (meaning you write the client before the code it calls). We typically think of autocomplete to help us with methods and variables that already exist. This is okay, but even cooler is when a method/class does not exist.
Try typing this code into a method (anywhere, really):
Who who = new Who();
who.whatUpMan("hi", 32);
Now left-click on the Who at the beginning. It will give you the choice to create a class, interface, enum, etc.
Now left-click on the whatUpMan. It will prompt you to create the method with the right parameter types and everything.
These are called "Quick Fixes" in Eclipse and they give you total freedom to code from the client "backwards" to classes it utilizes. And when you've already got the method, of course, control-space and control-shift-space (to see parameters for methods) are your friends.
http://eclipse-tools.sourceforge.net/EclipseEmacsKeybindings_3_1.pdf
Some more time savers that don't seem to be mentioned:
Ctrl+3 'Quick Access' which basically let's you reach anything without clicking around too much. E.g. type 'nav' in the popup dialog, rather than Window | Show View | General | Navigator or wherever it is.
Ctrl+O 'Quick Outline': when editing Java (and some other things), pops up a lighweight dialog so that you find anything in the file by a few keystrokes
Shift+Alt+T 'Refactoring', and things below that menu - look for shortcuts there, use 'Rename', 'Move', 'Extract method', 'Change method signature' often
Alt+Up/Down move blocks of code up/down without cut/paste
Alt+Shift+Up/Down select various levels of code (expressions,statements, methods, class) easily
Ctrl+1 on the selected code offers you cool stuff eg. Extract to variable/constant/method; Split variable declaration -- see others above, or just try it on anything
Ctrl+Shift+R find any file in the workspace, similar to Ctrl+Shift+T to find types
Ctrl + Shift + O : resolve all dependances automaticall. In Java, it's a life saver as it cleans old packages and add the required one without a single line to write.
"Right click" then "refactor" : all the features are handy, but I espacially love "rename" (Ctrl + Shift + R, c.f comments) because it will apply the changes to all the project. No more tricky find / replace wit regexp to do ensure you breal nothing else :-)
"Right click" then "source" : equally useful, with a special mention to "generate getter and setter" and "implement methods"
Ctrl + D : delete a line. Kinda cool.
I kind of remember CTRL+SPACE was the shortcut for autocomplete.
Another time-saver is formatting the code automatically using Ctrl + Shift + F.
Formatter preferences http://img187.imageshack.us/img187/5866/eclipseformatter.png
General Eclipse tips
Get rid of all the crap that you'll never use
if you do web-dev ... install the database, php, pydev, modules and plugins
install svn/cvs/git plugin
use Trac
have different code enviornments for different code types, i.e. one for python-dev, c++, and so on.
wait a few weeks to months before updating
i have about 100 premade mini scripts that i use frequently.
learn to develop your own plugins, as it's easy and fun.
For some applications, the answer is to generate the code using EMF. But the EMF learning curve is significant.
I would suggest go to Eclipse -> Preferences -> General -> Editor -> Keys and to configure your own keyboard shortcuts for all common tasks so that you can have custom keybindings that are perfect for you.
Probably this might not exactly answer your question but it is very relevant to your question title.
You can define templates in Eclipse to magically type and get a bunch of code typed for you. For instance you may type something like syso or sout to get System.out.println() in your Java code.
This can be done by following Window -> Preferences -> Java -> Editor -> Templates. You can also add a Template View, which you find at Window -> Show View -> Other -> Search for Templates.
Here is an image to clarify
* Original related answer in here as well.
Hope it is helpful to someone :)

What is the [shortcut/other way] for go to definition in Eclipse+Pydev

I used to use WingIde, where in a shortcut(f4, default) which I used quite often was Goto definition, which will open the definition file, and take me to it. Is there a similar shortcut for eclipse+pydev?
For Aptana Pydev, you have "Go To Definition": F3
(Andrew Falanga comments below that Alt+← allows you to return to the point you left)
The 'go to definition' actions enables you to get to a given definition.
It works well on 'self' tokens
It can work on methods / attributes from parameters (as the image below shows).
As others answered, F3 is the way to go, but going a bit further, you might also want to take a look at ctrl+shift+t to browse all the tokens available and ctrl+shift+r to browse all the files.
Assuming you mean "go to where a method/class/variable" is defined, in Eclipse, it is F3
Although the question is pretty time-barred, maybe this more general approach will help others looking for specific short-cuts in eclipse.
Help - Key Assist... opens a list of all available short-cuts, alphabetically sorted by description. ("Open Declaration" was the one looked for here.)
Window - Preferences - General - Keys lets you edit the short-cuts.
Actually it does not work when you set MSVC scheme. In eclipse mars go to
Windows->preferences then go to General->keys (or in type filter text type keys) then in Keys in type filter text type definition. Then you shall see in command below Python Go To Definition. In Binding text edit you can then set any shortcut you want.

How to highlight the selection in Emacs keybinding of Eclipse?

I have searched the Web for this, but with no luck. Any idea?
Thanks.
Try using the Emacs+ plugin available here:
http://www.mulgasoft.com/emacsplus
It provides a HUGE range of functionality - including the selection highlighting that you're looking for - that really helps the move from Emacs. I've only been using it for a couple of days, but it appears stable and integrates very well with the editor.
As described here, you can set emacs key binding to work in component editor in Eclipse
Go to Preferences -> General -> Keys.
Change Scheme to Emacs if you haven't done so already, so you can easily
spot the emacs key bindings.
Sort by Category and look at the "Text Editing" categories
Find the commands that you care about, e.g. Next Column, Previous Column
Select that command and click "Copy Command"
Set the binding to the key by pressing the keys, e.g. press Control-f to
generate "^F".
Change "When:" to "Editing Components".
Repeat for all the key bindings you care about.
So if, in emacs, selection is done by setting the mark (Control-Space) at the start of the region, then moving the point to to the end of the region, you could associate the appropriate shortcut to:
Text Editing > Select Text Start
Text Editing > Select Text End