How do I see the comment blocks above a sub I am calling while typing the sub name out in eclipse?
example is
$collector->get_collection();
right after I type -> the option list for all the sub calls shows up but when I scroll through each one I do not see the comments that go with that sub above the function call.
Maybe this is more a question for superuser? Anyway.
Unfortunately, this does not work.
There is no integrated print documentation/comment functionality in epic, at least for this kind of information.
I would like to have it, too!
The only documentation you can get inline is for perl builtins. When you double-click on a word, let's say system, you get a tooltip window with the short form of the
perldoc -f system call.
That's all.
You can get more documentation for modules or classes, when you mark a module (name) and call Help->Perldoc (or hitting F1 in my case), but not for functions or methods.
Then you get the perldoc in a different window.
What I do in your case:
Mark the method (after having written it) and hit F3, i.e. Open Declaration. It will jump to the sub and you can read the documentation. With the back keystroke or "Go to last edit location" I come back where I was.
This works as long as epic knows about the functions and methods, that is somewhat like:
- the module with the function has to be in your Projects Perl Include Path
- you have a use in your file for that module and the name is unique
- you use fully qualified function names
- you build your objects with My::Class->new instead of new My::Class.
Hope it helps at least a bit.
Related
I've just found speedbar and it's a wonderfully useful tool. I really like how it can drill into (python) files to show me a list of classes, methods and functions.
Is there any way I can get speedbar to auto-expand the tree of class/function references for the file in the currently active buffer?
It would be a bonus too if I could just expand to where the current cursor is; for instance, if the cursor was located in the foo function of the bar class, speedbar would expand to myfile.py > class bar > foo.
There is no canned solution for what you are asking about. Speedbar does, of course, know how to do it, but you will need to write a new command to do it.
I'll guess you might be interested in ECB, which can serve a similar function. It breaks the side window into multiple parts, and one of the windows does follow the cursor around in the list of tags. I'll guess this is what you want.
I am maintaining someone else's code. The code is written in C using GCC 4.4.3 on Linux platform. However, the code jumps around a lot and its difficult to find out where all the functions are called from.
In Visual Studio, there is a feature called 'Call Hierarchy' which will display where functions are called from and called to. Does Emacs (23.1.1) have any such feature?
The classic Emacs way to jump to calls is to use TAGS file and use the M-. command. I recommend using Exuberant C Tags with the following command in the root directory of your project :
ctags -e --c-kinds=+pxd -R .
Then using visit-tags-table you can open the TAGS file. With M-. you can jump to each definition or call to your keyword. Use C-u M-. to jump to another occurrence. Use C-x z z z... to repeat the search.
If you have many projects, you can create a TAGS file for each one of them and then call visit-tags-file to add the TAGS file to your list of TAGS files to search from.
Another classic way (the un*x way), is to use the command M-x find-grep to search for occurrences of your keyword.
http://cedet.sourceforge.net/symref.shtml
I'd like to quickly move point to a function in my Emacs buffer. I'd like to run some function and get a prompt asking me for the function name, with completion provided for every function defined in the current buffer.
I generally use etags to navigate around, but sometimes I'm looking for a framework method that's been overridden in several files. In these cases, I can find the file I need but then I'd like to quickly jump to the function there. There is a similar feature in TextMate where you can select a definition from a list in the bottom right of the editor.
Just to jump around functions in the current file? Use imenu. It's the simplest and lightest of all the alternatives listed so far and might be enough for what you want. It's also built into Emacs and has minimum setup hassle. It features graphical and textual interfaces. Anything extra and you'll be better off using one of the other excellent suggestions made here.
speedbar comes standard, and gives you a collapsible menu for each file in the current directory, by default middle clicking on an entry for a function definition jumps to that def. With emacs23 this was changed to the more normal leftclick.
You can use etags-select to select from multiple matching tags. But the answer to what you asked is imenu.
Icicles is probably closer to what you are looking for:
http://www.emacswiki.org/emacs/Icicles_-_Tags_Enhancements
It's an enhancement to etags and includes (among other things) the file name with the tag so you can tell if it's the one you are looking for.
try CEDET. It is a bit difficult to set up the first, but here is an excellent tutorial: by Alex ott
And when he gets installed, you can use semantic-complete-jump. pressed tab couple times, and it is also brings up symbol definitions.
If M-. brings up the wrong method, you can type C-u M-. to find the next one with the same name.
global gtags is very good
To navigate within the current file or a set of files that you select, you do not need a TAGS file. You can use Imenu. But it is better to use Icicles imenu commands.
Why? Because they let you use completion. Substring, regexp, prefix, or fuzzy completion. Combine simple patterns to match, or subtract them.
Command icicle-imenu is bound in Icicle mode to C-c =. Butyou can also look up just a command or just a non-command function (non-interactive), using command icicle-imenu-command or icicle-imenu-non-interactive-function.
These commands are multi-commands, meaning that they are actually browsers: you can trip among function definitions using keys C-RET or C-mouse-2 (direct jumps) and C-down (cycle). Hit RET or click mouse-2 to settle down at a final destination.
I use C-M-a and C-M-e to jump between the beginning and end of functions.
Otherwise, open up Speedbar and click the + icon next to a file name to view a list of functions contained in the file. Then click on the function names to jump to them directly.
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 :)
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.