Custom command for Eclipse on current file
Asked Answered
M

2

12

I would like to enhance Eclipse so that when I press a custom key combo--say Ctrl + Shift + E--then it will run a command on the current file (if my current buffer is foo.c then it will run `mycommand foo.c' in foo.c's directory).

Moony answered 15/12, 2008 at 22:54 Comment(0)
N
16

Open the External Tools Configuration dialog from the Run menu. Create a new configuration with the following settings.

Location: c:\mycommand.exe (alter to your needs)

Working directory: ${container_loc}

Arguments: ${resource_loc}

Under Prefrences->General->Keys you can setup a shortcut for "Run last launched external tool".

This should solve your problem.

Neutretto answered 15/12, 2008 at 23:26 Comment(1)
That works well enough, Stefan, thanks. One concern: if I want to have two different custom commands, I can't use them both. Furthermore, I have to remember which command I used last when I press the key combo, making the keyboard shortcut fairly useless in this case. Is there any way to do this that will let me assign a key combo to a specific action, or does Eclipse not let me do that?Moony
A
2

Also, make sure that your "resource" (foo.c) is selected. It happened to me that when testing the external tool and horizontally scrolling the output pane, the resource gets deselected. When you run the external tool again after probably having made changes to its configuration, Eclipse will pop up an error box about "empty variable" (e.g. ${resource_loc} ).

Alphanumeric answered 13/3, 2012 at 23:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.