Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse: put keyboard shortcuts on specific launch configurations [duplicate]

Tags:

eclipse

Possible Duplicate:
How can I bind a specific key to different launch configurations in Eclipse?

I am launching certain programs many times from the little dropdown menu next to the green run-button in eclipse.

Is there a way to bind keys (like F1 - F12) to those run configurations?

I couldnt find something like this in the preferences under "Keys".

like image 846
clamp Avatar asked May 16 '11 09:05

clamp


People also ask

How do I set keyboard shortcuts in Eclipse?

the main preference page can be found under window > preferences > general > keys (or faster: press ctrl+3 , type keys and press enter ). from here you can see all commands and assign/change their associated keyboard shortcuts.

How do I duplicate a line of code in Eclipse?

In Eclipse you can duplicate a codeline via the shortcut CTRL+ALT+Up/Down.

How do I change the shortcut for run in Eclipse?

Pressing Ctrl + Shift + L will open the current list of defined shortcuts, again pressing Ctrl + Shift + L will open preference page from where the shortcuts can be modified. Save this answer.

What is Ctrl Shift R in Eclipse?

Open project, file, etc. Ctrl+Shift+R. Open Resource (file, folder or project) Alt+Enter. Show and access file properties.


1 Answers

Currently there's no way to bind to a specific launch config (without writing the plugin code yourself). Here's an example of walking the launch configs looking for a named one:

public class LaunchRunAwayHandler extends AbstractHandler {
    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        try {
            final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
            ILaunchConfiguration toLaunch = null;
            for (ILaunchConfiguration config :launchManager.getLaunchConfigurations()) {
                System.out.println(config.getName());
                if (config.getName().equals("RunAway")) {
                    toLaunch = config;
                }
            }
            DebugUITools.launch(toLaunch, ILaunchManager.RUN_MODE);
        } catch (CoreException e) {
            throw new ExecutionException("Failed to launch", e);
        }
        return null;
    }

}

In theory, you would write a command that provides takes a parameter to pick the name, and defines an org.eclipse.core.commands.IParameterValues so you could see all of your launch configs in the Keys preference page.

F11 is Debug Last Launched and CTRL+F11 is Run Last Launched. You might have to set a preference in Preferences>Run/Debug>Launching to "Always launch the previously launched application". But that will just launch the last one, not switch between launches.

like image 73
Paul Webster Avatar answered Sep 18 '22 17:09

Paul Webster