I think some shortcut to create a method stub in eclipse might be useful. Does anyone know how to do it?
Type public_method (see Java/Editor/Templates in preferences for more options) or method name and press ctrl+space.
In Addtion to the accepted answer:
Typing pu for a public method (with returntype and name)is enough:
Type pu and then hit CTRL + SPACE and then ENTER.
Type your method name and hit Ctrl + Space.
Also worth noting is, type 'test' and hit Ctrl + Space and it will give you the option to create a test method stub.
How about loking to this link eclipse ref doc?
It says that : Alt + SHIFT+M" will do , plus many others.
If you press ALT + SHIFT+ S.
There comes a dropdown, then select the override/implement methods, from there you can setup and implement the method in the prefered way.
One other shortcut to create a method stub is ALT+SHIFT+M.
source:
http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-menu-refactor.htm
CTRL + 1
(COMMAND + 1 on Mac)
If no superclass method exists to copy and you typed something like "myClass.newMethod(myInt, myEmployee)", Eclipse can generate newMethod in myClass using the types of the arguments provided.
Related
In IntelliJ, when your cursor is inside a method, you can press Ctrl+P to view the parameters of the method.
What's the equivalent shortcut in Eclipse?
According to this command list, it's possible to show the list of parameter types for a method using Ctrl+Shift+SPace. Also, you can use the Ctrl+Shift+L shortcut to show a list of all shortcuts in Eclipse.
You can use Ctrl + Shift + Space to view the parameters of methods in eclipse
Ctrl + Shift + Space should work, Ctrl + P tries to print actually...
I want to search for a list of references on one method or class in IntelliJ. Is there any shortcut like Ctrl + Shift + G in Eclipse?
I would say that Ctrl+Alt+F7 is my favorite key combination for finding usages as it gives you a nice popup with good interaction.
Otherwise you can use Alt+F7 that will show you the same information in a tool window at the bottom that will stay there.
Look at the the Default Keymap Reference in the Help menu for all the built-in shortcuts:
for searching name of methods in whole project use:
Ctrl+Shift+F
for searching classes (Files)
Shift+F6
Ctrl + F7 Find usages in file that is, to find all places where a particular class, method or variable is used in the whole project in intellij IDEA
I really like the Ctrl+1 shortcut (hints for errors and mini refactorings) in Eclipse. Is there an equivalent for it in IntelliJ and Android Studio?
Alt+Enter
Personally I don't think AltEnter is particularly correct. Ctrl1 does lots of code generation like generating local variables given a method call etc.
CtrlAltV ... generates a local variable
CtrlAltF ... generate a field
AltInsert ... generate (drop down menu to generate all sorts)
Now, unrelated to the question but maybe helpful and in the same ball park is that the "foreach" short cut in IntelliJ is iter rather than for.
I also don't think ctrl+enter is the answer.
I'd say ctrl+alt+shift+t (Refactor this...) which I remapped to ctrl+1 is the closest thing to ctrl+1 from eclipse. It allows you to inline, extract code (variable, method, field etc.), move code, pull members etc.
Ctrl + 1 was one of my favorite shortcuts but unfortunately there is no exact equivalent shortcut for that. You can search for Quick fix in: File-->Settings-->Keymap, but you'll find nothing.
Although many people would say Alt + Enter is the nearest answer. but I think there are better equivalents such as Ctrl+Alt+Shift+t. It will give you some magic options.
You can also remap it to Ctrl + 1 by going to:
File-->Settings-->Keymap
Try pressing CTRL + ALT + v.
It will give the return type exactly of that method.
I think the "Other -> Show Context Actions" is very close to Ctrl+1 in Eclipse.
Suppose I know a function name, but I don't know which file it's declared in. What Eclipse keyboard shortcut can take me to the function I'm looking for?
What I'm looking for is similar to Eclipse's:
Ctrl + Shift + R
except it will search for method names instead.
Sidenote
With Visual Assist X, I can do this by using the "Find Symbol" feature, which is executed with:
Shift + Alt + S
This is an old question, but for the sake of people Googling this, Ctrl + O opens the code outline search, which is what you were looking for.
Yeah, this is an old question, but I have a better solution: what about F3?
And CTRL + O is what Windows users are looking for.
Not exactly a direct shortcut, but you need to go through the Java Search dialog:
(Ctrl+H):
(Sergei mentions in the comments that you might have to select "Declarations" in the "Limit To" section)
Not sure if this is exactly what you want, but if you Ctrl + H, that'll bring up the search dialog. The default option (for me, using the Java EE perspective) is a Java search. I can type in the method name, and then select the 'Method' radio button under the Search For block. Note that the default option (again, for me) for the 'Limit To' block was the 'References' radio button. I had to change that to 'All occurences' in order to see the method declaration, and not just callers.
Press CTRL + Left Mouse Button on the name your function. Eclipse will open the clicked file with this function automatically.
I use Momentics, so I'm not sure if this is in Eclipse or in Momentics plugin, but if it is Eclipse I think this is exactly what you need: CTRL + Shift + T.
Quick and dirty is to use Ctrl+Shift+Up/Down, which jumps between members (methods, variables) in Java.
If the method in question is on an interface, then using Quick Outline or F3 to jump to the definition will only take you to the interface definition. This isn't often what I want. Instead I hit, on my mac, Cmd + T on the method to get a Quick Type Hierarchy. From the type hierarchy you can go to the implementation of the method.
Simply hitting F3 by placing cursor on the function name will work for windows users.
simple 2 ways to function declarations:
Way 1: ( Whole workspace )
Ctrl + Left Click the function calling place.
way 2: ( within the same page )
press Ctrl + F to find dialog window and type n function_name and search.
these will redirect to function definition
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 :)