I'm not looking for an "Vim Plugin" for Eclipse. Instead, I'd just want a keyboard-shortcut to open the current Eclipse file within a new Vim instance.
Is there a quick and easy way to do that?
If you right-click the file in the Package Explorer/Navigator, you will see an Open-With menu item where you can select how the file should be opened.
Just select Window→ Preferences→ Workbench→ File Associations, select the file type, and associate an editor or program with it (if nothing else, you can use Eclipse's default text editor). You also can run programs outside Eclipse as external tools, invoked by selecting Run→ External Tools.
There's two ways to do this, the canonical way, and the hack. First:
Now, files of that type should show up in an external vim instance. Awesome, right? But that doesn't solve your problem of pushing the current buffer out to vim.
Instead, we're going to set vim as a "build tool", and have eclipse send it the current file as arguments. This may have some unaffected side-effects, based on your project settings, but look into them carefully if you experience things like unexpected re-building of your files.
${project_loc}
(this is a variable representing your project's top directory)${resource_loc}
(this represents your current resource's path)You should be all set! Now you can send your file to vim by using the menu
Run > External Tools > Send to vim
If you want to get fancy, you can even add a button to your toolbar.
Be advised, I've used gvim in the examples. If you'd like to use terminal vim, you'll have to call it appropriately based on the terminal you're using. For xterm, this would be /usr/bin/xterm -e /usr/bin/vim
, instead of /usr/bin/gvim
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With