Workspace Editor Macros in Eclipse - eclipse

Is there a way to record permanent workspace macros in Eclipse and assign them a shortcut key or template?
I'd like to automate some of the actions I routinely do. Workspace editor templates are not a solution since I need to include some conditional logic as well. For example check what is a symbol to the right/left of the cursor.

See my answer at How can I launch more than one debug session in Eclipse from a single click? . The same plugin can work for you as well.

Related

Eclipse autocomplete parentheses in control structures

I have a quick question that might save me a few seconds of annoyance every day. I know that eclipse can do a lot of autocomplete magic, so this might be possible:
As a programmer who learned with python, I constantly forget to surround contitions in control structures (like if or while) with parentheses. How do I make eclipse autocomplete opening and closing parentheses when I finish typing while or if?
I am aware that I can autocomplete whole structures with ctrl-space, but how can I configure eclipse to do this by itself?
Any help is appreciated.
So in stock Eclipse, the usual way to bring up assisted content is to type Ctrl+Space. The problem with this is that it brings up both Help Proposals and Template Proposals, with the Help Proposals displayed first. You end up wasting time scrolling down to find what you actually want from the Template Proposals. And there's just that much more clutter to choose from.
The solution is this:
Go Window->Preferences->General->Keys. In the type filter text search for "Template". This should bring up a "C++ Content Assist (Template Proposal)" line. Click on it. Now map this to whatever shortcut you'd like (I did Shift+Space because that's an easy one to do while typing). Make sure to click on the "Binding" option to do this. Click "Ok" and you're done!
If you ever want to add or change what is brought up by that shortcut, and for which specific strings it works, just go Window->Preferences->C/C++->Editor->Templates and you can edit those to do exactly what you'd like when using that newly assigned shortcut.
Hope this helps.
EDIT: I am unable verify if this works for PyDev, as I'm running Eclipse Oxygen, which doesn't currently offer PyDev or the Eclipse Marketplace Client plugin. However, my guess is this would still work in PyDev. Best of luck!
Sources:
Setting auto complete shortcuts in Eclipse
How to change the Control+Space autocomplete shortcut keys in Eclipse for Android
Thanks for any help, but the only thing that seems to work are workarounds. My prefered "solution" is to change the Auto activation triggers for Java in Preferences>Java>Editor>Content Assist from . to .iwfs, so that the autocomplete dialog automatically pops up when I start typing if, while, for or switch. Then hitting enter will do exactly what I needed.

Run eclipse editor action on entire project

Question:
Is there a way to run an eclipse action that is available from the context menu in the editor on every file of an project.
Actual Case:
I have to work with the leon3 and my dull mind has trouble enough understanding the code, that I do not want to scan lines to see if there is a semicolon hidden in there to see if there are multiple instructions or if the end if happens to be behind another instruction rather than on a line of its own (I missed an end if, which caused me to think that statements were conditional,...), therefore I would like to format the source nicely. I have access to Sigasi PRO which offers the option to "beautify" code as an operation in the editor. I would like to run this operation on all files in the leon project automatically.
Sigasi indeed only offers formatting in the editor at this time. In the Sigasi editor, you can format a selection or the entire editor's content. But, you can not trigger the formatting action without an editor.
I have not tried this, but I think you can achieve this with the Eclipse EASE project. EASE is a scripting environment for Eclipse.

How to rename/refactor a variable in Eclipse PDT in a Netbeans-like way

In the NetBeans IDE, changing a variable name in the parameters of a function also changes all occurrences of that name in the function. How can I get that behavior with Eclipse PDT? There is a Refactor → Rename item in the context menu, but it let me refactor only the file name.
This issue has been open since 2006 and you can vote for it in the PDT bug tracker #149818.
Code refactoring presence is the difference between PDT and Zend Studio as it is shown at the comparison page. So no, there is no way to do code refactoring in PDT.
It is quite easy now, to do this in Eclipse for PHP Developers. My eclipse version is Mars.2 Release (4.5.2) Build Id: 20160218-0600.
You just need to put your cursor over the php variable you want to rename, then Right-Click your mouse and select Refactor -> Rename. As soon as you do that, you will straight away see that all the variables, with the exact same name, within that php function, are now selected. You just need to start editing the variable. It will also give you visual cue, how all them are changed simultaneously, while you are editing.
The php functions within a class (locally not globally) can also be changed in similar fashion.
I find it easy, to use the keyboard shortcut on my mac, by pressing Command + Alt + R
Note: Please don't highlight the variable name, otherwise it behaves weirdly.

Tying a single operation to multiple "when" situations in Eclipse. Is it possible?

I'm looking for a way to tie a certain keyboard shortcut to running an Ant Task in Eclipse.
I'd like to do this from any place in Eclipse. From what I've seen, I could define a hotkey for "Run the last external application", but that obliges me to define a "when", that is, a place I want to be when that hotkey makes sense.
I guess I'll want to run that either when I'm coding or when I have the package-explorer open but Eclipse only seems to allow me to define a "when". Is there a workaround for this?
Better yet, is it possible to define that a certain hotkey combination can be ran from anywhere in Eclipse?
It sounds like you want to use the "In Windows" entry for the "When". "In Windows" should make the shortcut work within any Eclipse window, but not in dialog boxes. If you want it to work in dialogs as well, then pick "In Dialogs and Windows".
Read more about shortcut definitions here. The section labeled "Contexts" corresponds to the "When" field of the Keys preference page.
Update: There is a bug in some versions of Eclipse that cause the key binding described above to open External Tools configuration dialog instead of running the last external tool. The linked bug report indicates that this bug has been fixed in the forthcoming version 3.7.

Macro functionality with keyboard shortcuts in Eclipse?

Having used Netbeans for ages and being new to Eclipse I couldn't see any built-in Macro functionality in Eclipse. I found the Practically Macro plug-in but this does not seem to have the capability to add keyboard shorcuts. One needs to go through two menus and therefore two mouse clicks to run a macro using the aforementioned plugin.
This does not serve well for my need of frequent macro applications. Is there anyway to have very simple Macros using keyboard shortcuts in Eclipse? Or should I start writing my own Eclipse plugin for this? Or perhaps use another light weight tool for this purpose? Do you have any suggestions?
There doesn't seem to be anything else than Practically Macro for Eclipse. Once you use a Macro, you can press Ctrl-Alt-P to replay that. This helps a bit, but when you want to switch between a couple of macros back and forth doesn't help much.
Not sure about this Macro plug-in you're using, but you can modify keyboard shortcuts (Helios) in Preferences->General->Keys.
Testing PracticallyMacro I found that it did not record right clicks but I was able to find a perfect utility 'TinyTask' and 'TyperTask'. The former can export record and save as small 'exe' files which can then be added as external Eclipse builders the latter can automate tasks based on typed characters - epic.