Archive for August, 2009

Seemy integration of Vim in Eclipse

author Posted by: whaledawg on date Aug 2nd, 2009 | filed Filed under: general

So in my last post I mentioned that I want to start doing mobile apps and I chose to work with Android(I’ll explain why later). And Android has proven to be great, but developing in it has forced me to use Eclipse, which is…less than great.

Now when I say forced it’s not like anyone from Google came to my house and threatened me but all the learning material I’ve come across, from the free stuff on the web to published books to what Google puts out themselves, assumes that you are using it. There are some explanations of how to do things without Eclipse but when you’re learning something you should always try as best you can to mirror the environment of who ever’s teaching. It helps narrow down the origin of errors.

And when I say it’s less than great I don’t mean it’s bad. I just don’t like IDEs, and for 2 main reasons. They hide things I should know from me and force me to do things their way. As an example of the first one, Eclipse has this nice feature that allows you to hit CTRL-SHIFT-o and it will automatically import any packages you need for a java file. Very convient. Except now I don’t know what packages corrolate with which objects. Even the most dynamic of languages force you to import foreign code expliciatly, that tells me that this is information the programmer should know.

As an example of the second one, it’s a pain in the ass to edit files in Vim. Every other text editor is notepad to me. I tried googling around and there are a few ways. The first if viPluggin, which seems good but it’s not free and to be honest I’m going to try and ditch Eclipse as soon as possible. Theres vimpluggin which I installed but it doesn’t work right/well. I couldn’t get arguments to Vim and I kept having to right-click and open-as to switch between Vim and the native text editor. And cosidering I sent a question to the support list and was promptly offered a deal on pills to make it ‘Thicker, longer, better.’ I’m going to assume it’s not supported anymore. I didn’t try Eclim but that seemed to be going backwards, adding Eclipse features to Vim. I need to make sure my developement environment is as close as possible to standard.

So what am I really looking for? I’d like to be able to edit files with full Vim functionality(including using my .vimrc file) and use the full feature set of Eclipse at the same time. And I’d like to be able to jump from one to the other seemlessly. That I did not accomplish(hence the title) but I have a hybrid approach that comes pretty close.

HowTo

So my two pronged approach involves installing VRapper so I can quickly switch to a Vim like navigation scheme within Eclipse. 4 keyboard strokes and I’m there. But it doens’t have the full functionality I need or take rc files(I can’t live without the elflord) so I used Eclipses built in ability to use an external editor. It’s a bit slower to start and switch back and forth but it works adequatly.

Elflord

Setting up VRapper

VRapper is an open source project that is constantly evolving and adding new features, but currently missing quite a few. Still, being able to navigate with the home keys and yank lines makes installing this worthwhile.

First, you have to add the repo path to your software updates. Click on Help->Software Updates:

You should the software window. Click on the tab Available Software and the button Add Site:

You’ll get a popup window that let’s you…add a sight. Go ahead and put in http://vrapper.sourceforge.net/eclipse-update-site

Then click OK and you’ll have this repo added to your list. Select Vrapper and then press Install

Then just click through until it starts installing and restart. You should now notice a new button on your toolbar:

Pressing the button toggles Vim edditing mode on and off. Congratulations, you now have some vim functionality available to you. However, it’s still kind of a pain to use. You have to close whatever you’re working on, click the button then open it again. I could open it in Vim for that much effort.

So what we’re going to do is set up a hot key to toggle Vim mode, then we can switch back and forth from VRapper to native Eclipse editing with a few keystrokes.

First we need to open up the preferences. Go to Window->Preferences

Then expand General, select Keys and type vrapper into the filter.

Then type any key combo you want into the binding box(I chose VV) and done. Now typing those keys toggles Vim mode on and off. You still have to close and reopen the file, but I can do entirely from the keyboard(CTRL-W closes, F3 opens a file). So I type CTRL-W SHIFT-v SHIFT-v F3 and I can jump from one mode to the other. There’s probobly a way to macro that all into one keypress for Eclipse but that’s fast enough for my needs.

However, VRapper is still missing a lot of Vim functionality. No macros, no rc files, etc. So I also want to be able to open files from Eclipse directly in gVim.

Setting up gVim

This is actually pretty easy using Eclipse’s ability to call external editors. If I could find a way to do this with keystrokes instead of using the mouse I wouldn’t even bother with VRapper.

optional

I don’t call gVim directly from Eclipse because I want it to behave slightly differently when I’m editing files from Eclipse. This means I set up a little bash script in my home directory that looks like this:

/usr/bin/gvim -U /home/whaledawg/.vimeclipserc -- $1

That calls gVim and gives it an rc file I use just for Eclipse. The rc file looks like this:

set noswapfile
set nobackup
set noswapfile
set nobackup

Note: if you do this then the bash script must be named gvim. gVim checks the name of whatever calls it and it must be gvim or it won’t work.

/optional

OK so again we need to go to Window->Preferences, expand Gernal but now we’re going to choose File Associations. If you click add you can add new file associations here(you may need to do this for *.java files) and if you select a file type you can see all the associated editors in the bottom window:

Clicking Add(next to the associated editors) allows us to add a new editor to that file type(these are the editors that appear when you right click a file in Eclipse and choose “Open with”) From the pop up window select External Programs and then click Browse. If you created my bash script above, then you would browse to tha script(make sure it’s permissions are executable) or if not you will browse to wherever gvim is on your system.

Now if you right click on a file of that type and mouse to Open With you’ll see gvim as an option. Hurray.

There’s still a minor problem though. If you have a file open in Eclipse and open it again with gVim it will either not update the changes to Eclipse or will give you an annoying prompt. Let’s fix that.

Again under Window->Preferences->General, we’ll find Workspace. You don’t need to expand Workspace, just select it and you’ll see some options. Check Refresh Automically and it will automatically update your open files in Eclipse if you edit them with an external editor.

Click OK and that’s it.

Now you have a quick way to get most of the functionality in Vim and a slightly more cumbersome way to get the full functionality. While far from perfect, this approach has worked for me so far, at least until I’m able to dump Eclipse completely(which I hope to do in the near future).

  • chicago bears 61
  • chad ochocinco height and weight
  • chicago bears posters
  • randy moss height
  • cspan kucinich
  • dope
  • bengals kids jersey
  • greg olsen 2009 calendar
  • chicago bears schedule 2011
  • hp support chat
  • randy moss bio
  • battleship kirishima
  • c span youtube obama
  • gregg olsen books
  • hp support hard drive replacement
  • search dog foundation
  • bengals for adoption
  • tea party for kids
  • la ink phone number
  • battleship bismarck wreck
  • freida pinto miral
  • hp support 530
  • chicago bears 96
  • chad ochocinco yesterday
  • tea party 8 28 09
  • freida pinto chanel
  • wolff
  • randy moss college
  • agents
  • chicago bears number 17
  • wave
  • hp support venezuela
  • chicago bears 2009 roster
  • la ink jabberwocky
  • disconnect
  • bengals merchandise
  • vince young stats
  • la ink corey
  • search and seizure
  • chad ochocinco johnson
  • summertime
  • search engines of the world
  • mtv 25 lame
  • search engines other than google
  • hp support 6930p
  • chicago bears 08 record
  • randy moss 07 08 highlights
  • bombings
  • dis boards cruise
  • bengals images
  • randy moss 98 vikings
  • rooms
  • search 32
  • freida pinto jeansfreida pinto kissing
  • new england patriots 3 4
  • search engines usage statistics 2010
  • whaler
  • search tumblr
  • tea party chicago
  • dis systems
  • zara phillips school
  • meeting
  • search vim
  • connie
  • stadium
  • connecticut 97.7connecticut attorney general
  • connecticut lottery
  • mtv website
  • connecticut airports
  • mtv rivals
  • volunteer
  • denso
  • la ink 03x05
  • zara phillips kids
  • chicago bears 09 draft
  • tea party hats
  • new england patriots 07
  • la ink games online
  • tea party nj
  • gearbox
  • battleship texas hours
  • dis pater
  • new england patriots 84
  • frazer
  • hp support greece
  • chad ochocinco quotes video
  • hull
  • vince young usc
  • geography
  • dis windsor wi
  • 22lr
  • vince young football camp
  • want
  • bea karp
  • chicago bears 17 lisa lampanelli
  • vince young released
  • la ink tattoos
  • search with image
  • bengals xxiii
  • bengals tryouts
  • vince young depression
  • chicago bears 1985
  • tea party agenda
  • kayaking
  • zara phillips baby
  • vince young 3rd 30
  • la ink season 6
  • new england patriots wiki
  • search engines for jobs
  • sense
  • bea test
  • chad ochocinco parents
  • bea luna
  • bea 4603
  • beagle
  • bea 2011 map
  • search operatorssearch people
  • disassembledis boards
  • hp support center
  • tavern
  • sahara
  • la ink season 5 premiere
  • connecticut sun
  • iver
  • anual
  • new england patriots 50
  • bea diy
  • chicago bears football club
  • bengals games
  • chad ochocinco quits football
  • randy moss arrested
  • widget
  • la ink show
  • bengals new uniforms 2012
  • mtv true life
  • battleship wilmington nc
  • zara phillips yachtzara phillips zimbio
  • bengals forum
  • vince young rivals
  • acessories
  • 10000
  • c span shelby foote
  • chicago bears pictures
  • cingular
  • bengals arrests
  • diamondback
  • search 78search 800 numbers
  • aires
  • bengals cheerleaders tryouts 2011
  • dis poem
  • c span kozol
  • dis lyrics
  • accumulator
  • freida pinto 1995
  • mtv overdrive
  • winston
  • la ink bam margera
  • new england patriots xxl
  • sling
  • dillon
  • new england patriots espn blog
  • search google cache
  • search 990 filings
  • hp support assistant review
  • greg olsen twitter
  • chad ochocinco age
  • connecticut lakes
  • search engines compared
  • mtv 30 years
  • vince young dadvince young eagles
  • centurion
  • connecticut 7 day weather forecast
  • bea verdi
  • connecticut education
  • new england patriots helmet
  • search engines 9
  • dist 91
  • cspan washington correspondents dinner 2011
  • chad ochocinco and cheryl burke
  • search domains
  • eyelet
  • whirlpool
  • la ink watch online free
  • battleship classes
  • search engines and flash
  • connecticut 104.1
  • chad ochocinco quickstep
  • intrest
  • mtv cartoons
  • vince young jay cutler
  • protective