Eclipse local Find Replace macro with predefined terms? - eclipse

How would one automate a commonly used search replace action in Eclipse?
My current workflow is as follows:
Double click on function bracket selecting function
Ctrl-F opening Find / Replace dialog
Type "foo." in Find box (alternatively can use pulldown menu but that is slower)
Type "bar->" in Replace box
Press Replace All button
Ideal macro would do all of the above bound to a single command.
From my search, it doesn't look possible in plain vanilla Eclipse, but perhaps there is a plugin which can do this?
Using: Eclipse Helios for C/C++ developers

Try the Practical Macro plugin.
There is even an example on the forums showing a Find/Replace macro definition.

Related

Is there a way to add Smart Insert to a custom Eclipse Editor?

Eclipse has a feature where it automatically inserts things. (eg. closing curly braces after pressing ENTER on an opening curly brace)
This is found in Preferences > Java > Typing.
I would like to add a similar feature in a Plugin of mine that automatically closes DO-Blocks with an END statement and moves the cursor to inside the DO-Block.
I have already looked through the documentation of Eclipse but I can not seem to find a way to trigger an action on ENTER and with a context.
Is there a simple way to do this?

How to set shortcut to a line of code in Eclipse IDE editor

I'm after a feature in eclipse that allows me to allocate a shortcut to a line (say line number 55) then go somewhere else in the same file and hit the shortcut then IDE shows me the line 55. I have used this feature in Delphi IDE. Using CNTL + number keys[1,2,...,0] a shortcut to line where the curser is will be created. This shortcut only has effect within the editor and each opened file would have its own shortcuts.
Is there such a feature in eclipse? Is there any plugins out there which adds this feature to eclipse?
Regards,
Ali
By default there is no shortcut defined for this task.
I use to define my shortcuts in Eclipse in "Windows/Preferences/General/Keys" type bookmark in the filter text and select the commands you want to define the shortcuts.
My current shortcuts are:
Alt+Shift+B, Alt+Shift+A: Add Bookmark;
Alt+Shift+B, Alt+Shift+V: Show View (BookMarks);
But, I agree, still is not fast as the Delphi predefined shortcuts.
Update 1:
This plugin (or its sucessor) seems to offer the option. From their site:
Add a numbered bookmark at the cursor: Alt>+[digit]. This creates a
quick bookmark with the specified number using a "single" keypress.
Only one bookmark of the given number can be present in the workspace.
Setting the same number bookmark again will clear the earlier
instance.
Goto a numbered bookmark: Alt+Shift+[digit]. Moves to the bookmark as
it was set using Alt+[digit].
Update 2:
Tested (Eclipse Indigo) and it worked like a charm.
You can add Bookmarks to the code fragments you think are important to you in eclipse.
I referred this link for the same purpose.

Double Clicking Highlighting

In Notepad++ if you double click a word to highlight it, all the occurrences of the word in the file are also highlighted, a feature that is quite handy for finding where variables are declared/used.
Does the eclipse editor have this functionality? :) If so, how can I turn it on?
For the Eclipse Java editor, you can go to Window->Preferences in the menu, then Java->Editor->Mark Occurrences in the options tree and check off anything you want highlighted in this way.
Note that the editor understands Java scoping rules, so if you have 2 local variables with the same name in two different functions, it will only highlight within the current function.
I found a plugin called eclipse-glance that searches like notepad++ but without double-clicking
http://code.google.com/p/eclipse-glance/
Closest to original what I have found is alt-shift-O
For activate double click hightlighting in Eclipse:
activate double click hightlighting in Eclipse
For change color of double click hightlighting in Eclipse:
change color of double click hightlighting in Eclipse

Does Eclipse have a plugin for code clips like in Coda?

There is a very useful "Clips" feature in Coda, does Eclipse have such feature?
What it does is pretty simple, you save a code clip once, which you use very often and assign it a shortcut and when you want to re-use you type the shortcut and it automatically pastes it and sets the caret at the defined position.
e.g. when I type 4dom and press TAB it types this:
jQuery(function($){
//puts cursor here
});
so, how do you do this in Eclipse?
In Eclipse they are called Templates. You can find this in Window->Preferences then JavaScript/Editor/Templates.
It will allow you to create or edit.
Similar function in Eclipse is called Snippets.
Find it by doing this:
click on Window > Show View > Other > General > Snippets

short for custom surround with

Is there any shortcut for surrounding any selection with a template from "Surround With..."?
In this special case, I defined a surround with brackets template... It would be a great enhancement to have such a shortcut.
Thanks for your help in advance.
The only shortcut I know about for surround templates
(that is for templates with ${line_selection} variable in their definition)
has been introduced in eclipse 3.2 (refined actually in eclipse3.2 M4)
It is the "Surround With Quick Fix" mechanism
(source: kano.net)
Assign a shortcut to Quick-Fix (CTRL-1 by default), and if your selection is eligible ((contains a line), all compliant templates will be displayed in the Quick-Fix dialog.
You will then be able to choose the appropriate surround template (like the one you defined).
Answer from #VonC is not working on Eclipse Kepler. Use short cut for show surround with quick menu.
Select one or more lines in java editor press Alt + Shift + Z then you will get the popup context menu as shown below(Menu items differ based on the region of selection).