Opening Files in Eclipse From The Command Line

2014-09-29 19:53:50

I really enjoy working from the command line and spend a lot of my time there. I have been using eclim to work on a project in Java. I am much more efficient searching for and editing files in vim, but would rather use Eclipse when it comes to running the debugger. I found myself regularly working on a file in vim and then wishing that I could just pop it open in Eclipse instead of swiching to Eclipse and searching for the same file again. After a bit of searching and some trial and error I came up with the following command.

				open -b org.eclipse.platform.ide /path/to/file 
			

With a small amount of viml I was able to add the following to my .vimrc

function! OpenInEclipse()
	silent !open -b org.eclipse.platform.ide % 
	redraw!
endfunction
command! OpenEclipse call OpenInEclipse()
			

Now whenever I want to context switch I can just type :OpenEclipse and the file that I am currently working on will open in Eclipse.