Tuesday, December 4, 2007

vi plug-in for Eclipse

During the past few years, I've gotten so used to using vi that my fingers have memorized some of the key bindings. Now that I'm using the Eclipse as IDE, I'm having withdrawal symptoms... like constantly typing :wq to save current file, or '/' to perform a search. It's just so convenient to not have to lift my hand over to the mouse to do some common editing tasks.

Much as I love the convenience, though, I'm not willing to give up the powerful Java & C/C++ editing features of Eclipse: outline view, type hierarchy, continuous build, among many others. Given this dilemma, what is a developer to do?

Thankfully, Eclipse is an extensible IDE/platform and creating plug-ins has never been easier.
So I did the next best thing: I tried to create my own plug-in that emulates vi inside the Eclipse IDE (specifically, inside the text editors).

So, let me introduce to my own (pre-alpha) version of the Eclipse vi plug-in.

Here's how to install it:
  1. Inside Eclipse, go to Help->Software Updates->Find and Install...->Search for new features to install
  2. Click the New Remote Site button. Enter the information below when prompted:
    • Name: Eclipse vi plug-in (or whatever suits you)
    • URL: http://eclipseviplugin.sourceforge.net/update/0.x/
  3. Click Finish. Eclipse will try to download the plug-in from the above site.
  4. Once the download is finished, you will be asked to select the features to install. Just select All then hit Next.
  5. Accept the license... blah blah blah.
  6. Next. Then Finish. You will be prompted to restart Eclipse shortly afterwards. Please do.
  7. After restarting, try opening a text, Java, or C/C++ file.
  8. Press Ctrl+4 (my temporary equivalent of vi's ) inside the editor to go into vi command mode
  9. From command mode, you can press i (insert), a (append), or o (insert line) to go back to edit mode. Or just click the mouse anywhere inside the document.
Voila! The convenience of vi at your fingertips. Literally.

Mind you, it is still pre-alpha (v0.0.1), and thus sorely lacking in features and probably ridden with bugs too. If you find some, please don't hesitate to report it in the project's Bugs or Feature Requests page. Please be kind as I am only doing this in my free time :-)

Here are some of the other commands that work so far:
  • :w (save)
  • :wq (save and close)
  • :q (close)
  • w (next word)
  • b (previous word)
  • $ (go to end of line)
  • ^ (go to start of line)
  • % (find matching bracket - you need to be in a Java or C/C++ editor for this)
  • most navigational keys (h, j, k, l and arrow/pgup/pgdown keys)
  • delete commands (x, dw, d$, dd, db)
  • u (undo)
In the future, I plan to add support for:
  • Find commands (/, ?, *, #)
  • Repeat previous command (.)
  • Command count (e.g., 3x to delete 3 characters)
  • Other neat vi features
  • Text editor (UI) enhancements such as status line, popup dialogs, preference pages, etc.
  • Help pages
Members & contributors to the project are most welcome, especially those with Eclipse platform knowledge!

In the next posts, I will try to document some of the experiences in developing the plug-in, for the benefit of those who might also be interested in Eclipse plug-in development. Stay tuned!

[Update (12/05/2007) - Ack.. I forgot to set the compiler level to 1.5. As a consequence, v0.0.1 will not run on 5.0 JREs. It's fixed now in v0.0.2]

8 comments:

Unknown said...

outstanding! Thanks for sharing.

Wei Ma said...

nice work! I have been searching this for a few days.

Mr. Fru Stration said...

Please get it done NOW

anon said...

Thanks for taking on this project. You have no idea how popular you will be once you get this done!

Puneet Gupta said...

Thanks a lot!

Yota Moteuchi said...

nice plugin, thanks!

Unknown said...

This sounds very promising. I always wanted vi/vim keybinding on eclipse. I know they have it on Netbeans.

My question:
Does it work with the latest Eclipse IDE? I have Galileo and when I click on control 4, nothing happened.

Android app development said...

These all comments are very sharing and good.This is one of the pretty collection.Keep it up.
Android app developers