The Dev Blog

Putting Family Management on Rails!

How I learned to Love vim and Ditched Eclipse

Posted by Guy Naor Thu, 08 Mar 2007 13:03:00 GMT

For the longest time, since starting to work with Ruby and Rails, I used Eclipse with RadRails and RDT for coding. It's a pretty good IDE as far as IDEs go, and has nice Ruby/Rails tools to make development a lot easier. It also has a VERY nice subversion interface. One of the best I've seen as far as working the way I like to work.

On the down-side, it's a performance hog and the editor itself is so-so in features.

As I also do system admin chores on remote computers, I always use vi as well. And for many quick and dirty tasks, I use it even localy. Developing on a Linux machine, I always have some terminal windows open. Slowly I was pulled to do more things with vim, until I realized I prefer being in it than in Eclipse. Now I spend 90% of my time in vi, and most of my projects never even see Eclipse.

Why did I switch? First and foremost vi as an editor is really good. And lets keep the vi/emacs wars for another time. I'm sure emacs is a really good editor as well. I just have to choose my tools. Can't use all of them. Second thing is speed. I NEVER have to wait for vi. It's always super fast and super responsive.

But to make vi really useful with ruby and rails, some additions are needed. After all, I want synax highlighting, macros, easy way to open files, etc... So here is a list of vim scripts/plugins I use and recommed:

rails.vim, eruby.vim, ruby-macros.vim, rubycomplete.vim

There are many more additions and plugins on the vim site. Please note that some require the newer vim 7 to work.

Another option is getting the rails-vim gem: sudo gem install vim-ruby. Please note you have to then run the vim-ruby-install.rb script to complete installation.

So now that we have vim loaded with the additions, where do we start? Granted, the learning curve is steep! And don't get me started on using the esc key so much, that I keep doing it in Eclipse ;-). But as the editor is our main tool of work, learning it pays for itself later with productivity. vim has a lot of help written for it, and you can access it from within vim, but I prefer browsing it on the internet. So start with this short tutorial, and then bookmark the main help file. And for the rails related parts, take a look here. Some of the things it does are just awesome. I open files faster with :Rfind than on a tree in the IDE browser! And check out the partial extraction. That one is unbelievable.

vim also has the GUI version in gvim. And there you can open multiple tabs and have an IDE like file browser. Use that if you are more comfortable with the mouse and a real GUI. It's also easier to stasrt with as it has menus for the more common commands.

One thing I did that really got me into more advanced editing, is deciding that whenever I want to do something, and I don't know how to best do it, I stop resorting to hacking a solution with the things I know, and look for the real solution. In a few short weeks I learned more than in the last 5 years...

So give vi a try. Give yourself some learning time, and you'll never look back!

BTW, I also use svn from the command line. I'ts so much faster than from Eclipse that I don't mind the few keystrokes it takes to get things done. It's so much faster!

Posted in , , ,  | 41 comments

del.icio.us:How I learned to Love vim and Ditched Eclipse digg:How I learned to Love vim and Ditched Eclipse spurl:How I learned to Love vim and Ditched Eclipse wists:How I learned to Love vim and Ditched Eclipse simpy:How I learned to Love vim and Ditched Eclipse newsvine:How I learned to Love vim and Ditched Eclipse blinklist:How I learned to Love vim and Ditched Eclipse furl:How I learned to Love vim and Ditched Eclipse reddit:How I learned to Love vim and Ditched Eclipse fark:How I learned to Love vim and Ditched Eclipse blogmarks:How I learned to Love vim and Ditched Eclipse Y!:How I learned to Love vim and Ditched Eclipse smarking:How I learned to Love vim and Ditched Eclipse magnolia:How I learned to Love vim and Ditched Eclipse segnalo:How I learned to Love vim and Ditched Eclipse

Comments

  1. Bojan said 2 days later:

    So, how did you?

    I am looking for alternatives to JEdit for Ruby/Rails and other development.

  2. Guy Naor said 2 days later:

    Bojan,

    I'm sorry. This wasn't supposed to be released yet, as I didn't put any content in. It's comming soon :-)

  3. Guy Naor said 11 minutes later:

    Bojan,

    It's finally out! Sorry for the delay.

    Guy.

  4. Sébastien Pierre said about 1 hour later:

    There is an editor which is very promising. It's called "Evergreen" and is under active development. Check it out at http://software.jessies.org/Evergreen/

  5. Guy Naor said about 1 hour later:

    Never heard about Evergreen. Seems very interesting.

    Does it have any ruby/rails integrations?

  6. Oliver said about 2 hours later:

    Well, I haved decided somewhat along the same road as you did. I am going to ditch TextMate for Vim, Screen and rails.vim. Have you ever tried to call :Rserver in Rails mode while running a Screen session? This gives you a sleak integrated environment, a brilliant editor and well, Vim on a decent terminal window rocks. :)

  7. Guy Naor said about 2 hours later:

    Hey, the :Rserver trick is cool. Never tried it before.

    I think there's a lot to find in it still. IT has a lot of power.

  8. http://stable.cowoh.org said about 2 hours later:

    "It's always super fast and super responsive." Not always. With syntax hilighting turned on and long lines it can really crawl to a halt and eat up insane amounts of resources.

  9. mde said about 2 hours later:

    You can try using Ctrl+[ (Ctrl key plus the left square bracket) instead of the Esc key in Vim. I've found it's much faster because I don't have to move my hands from the home keys -- less chance of repetitive stress! :)

  10. jeramey said about 3 hours later:

    Another thing you can try is, if your software supports it (or you're fortunate enough to have a fully remappable keyboard like a Kinesis) is to remap the Esc key to where Caps Lock is. Most people never use Caps Lock anyway, and it is prime keyboard real estate since it is typically also on the home row.

    Emacs users often map Ctrl there, but even when using Emacs I find that I prefer to have Esc where Caps Lock is.

  11. Sneaky Pete said about 3 hours later:

    Not moving your hands doesn't prevent repetitive stress. In fact, the effect is the exact opposite. Quick examination of a few books on the subject will confirm that.

  12. John said about 5 hours later:

    jeramey, I'm one of those lucky Kinesis (Contoured) users. For me, the '[' key is pretty easy to reach, so I don't bother with the remap. Also, regarding Emacs, I'm not sure I've ever even used the Esc key for anything...

    Sneaky Pete -- the point about not moving your hands: I think not moving your hands much is a good thing, but the trick is to have them in a good comfortable position to start with. For me, that's with the keyboard on my lap, lap parallel to floor, feet up on old x86 box, elbows resting on chair armrests. This way, the back of your hand stays in-line with your forearm, and your fingers dangle down onto the keys.

    Yup, I'm hoping to stave off wrist problems for as long as possible. :)

  13. John said about 5 hours later:

    Oh, by the way, using the mouse bothers my hands much more than just using the keyboard. Controlling the editor with your fingers divides the load by 10. Using the mouse makes one finger do all the work over and over.

  14. Cezar said about 6 hours later:

    The feature in Eclipse that I can't find in vim is the code outlining. For the size projects I work on it's pretty much required for me to find my way around. Have you found something like this in vim?

  15. Emil said about 7 hours later:

    @Cezar: You can use folds. See :help fold, and maybe http://eigenclass.org/hiki.rb?Usable+Ruby+folding+for+Vim

  16. Doug said about 8 hours later:

    Check out the SVN plugin too!

  17. Doug said about 8 hours later:

    Check out the SVN plugin too!

  18. Nathan said about 9 hours later:

    I just switched from Vim (which you mistakenly over and over again call vi) to emacs. Both editors are very nice. Emacs seems to be a bit more powerful in terms of scripting. However either is a valid choice as far as I am concerned.

  19. Greg said about 10 hours later:

    You can buy (for a few Euros) a vi plugin for Eclipse. It's not perfect, but it's not too bad.

    http://www.satokar.com/viplugin/index.php

  20. Tiago Serafim said about 11 hours later:

    Hello again!

    Nice point... I moved recently from eclipse too.. but to textmate and I´m loving it.

  21. Guy Naor said about 11 hours later:

    Tiago, TextMate isn't even an option for me. Dev done on Linux...

    BTW, I'm uplaoding an update to acts_as_rated. Just an improvement in the find_by_rating. Following that, another updated with a host of new functions will also be uploaded.

  22. Sarcasto said about 12 hours later:

    Here son use this handsaw to chop down that oak tree and put away that chainsaw it's cumbersome and clunky. It will take you longer to chop down that tree but you doing it the way our grandfather did. Great just want I want to do is go back and us and editor that I have to remember all the key combinations to do anything kinda like using old WordPerfect.

  23. Guy Naor said about 12 hours later:

    Sarcasto, I think your analogy is wrong. I rather use the chainsaw - it's a bit dangerous, but very fast. I rather not use this space age Laser cutter. It is VERY nice and has lots of functionality. But the truck that comes with it to power it, is a bit too much for me ;-)

  24. Chris Eidhof said about 12 hours later:

    Very cool! Did you ever take a look at svnvimdiff? That's svn diff combined with vim, I love it. I used to work in a very bloated IDE, and use Windows and TortoiseSVN, but now I've finally switched to Mac + vim + Terminal.app full-time. And I love it.

  25. regeya said about 12 hours later:

    Not doing rails work but working with ruby, I find I prefer jEdit...but to each their own. :-D One thing I really miss is integrated Subversion support; for that, I just switch to a terminal right now, but that's a bit inconvenient.

    I have mine set up to be a bit like TextMate--there's a lot of TextMate envy outside the OS X world--but it's not the Most Perfect Interface ever. I like it better than trying to remember vim commands. I have a terrible memory for such things. I remember basic key movement commands, entering and exiting edit mode, :w, :r, :w! and that's about it. Anything else I need a reference for, and if I need a reference it's not worth it. :-D

    For the record, I'm running jEdit on a G4/450 "Sawtooth" and an ancient desktop based on a C3 Ezra running Xubuntu. So no, I don't consider either of those to be the truck that powers the space-age laser cutter.

  26. Steve said about 13 hours later:

    You may want to check out vimmate, I've only started using it but it seems to do a lot of things I've been looking for for rails development.

    http://vimmate.rubyforge.org/

  27. Bojan said about 19 hours later:

    I am using JEdit too. I really like some features like multiple and rectangular selections. I hate not being able to set prefered encoding per project.

    Wonder how vim works on windows? Guy do you use gvim or vim?

  28. Guy Naor said about 21 hours later:

    Bojan, rectangular selections are easy with vim - Ctrl-v initiate rectangular selection, while Shift-v is for line selection mode (always selects full lines).

    I use almost always vim, though I do use gvim from time to time. The way I work is I have multiple tabs open in the terminal for different projects, and I use vim inside those.

  29. Albin said about 22 hours later:

    I map the jk combination to Esc. It's a combination rarely used in normal typing, and it's right on the home row. It's the fastest map that I've found.

  30. supersaurus said about 23 hours later:

    or you could use viper with emacs. you get to keep the convenience and terseness of vi (but much improved over the original) and still have the power of emacs. to those who cry "the worst of both worlds!" I say: pish tush! nothing of the kind, it is the best of both!

    viper-mode comes with emacs, read about it in info.

  31. viaddict said 1 day later:

    dude, there's a vi plugin for eclipse. some of it is quirky, but it's great to have the best of both worlds.

  32. Guy Naor said 1 day later:

    Steve, I downloaded and installed vimmate, but still can't get it to work. From the screencast it looks great, so I'll work on making it work and try it.

    viaddict, is this plugin able to do all the vim text handling, or it's mostly a key-mapper?

  33. Steve said 1 day later:

    Guy, I'm on debian and it worked out of the box. I just did gem install vimmate. I did have to install gtk2 to get the console functionality working. I haven't tried it on windows. Let me know what you think once you get it working or if I can help out.

  34. casey said 1 day later:

    Interesting... I use PyDev (Eclipse plugin) for Python development, but end up having to use vim anyway on the development server.

    Maybe there's something like this for Python?

  35. Guy Naor said 1 day later:

    Steve, I'm on Fedora Core, and it installed fine. Then I installed the gtk2 package, but on launch it fails with some uninitialized constant. It's missing something, but I didn'thave the time to look into it. Hopefully I will have time over the weekend.

  36. Guy Naor said 2 days later:

    Casey, try to run this search and see what comes up. Seems there's a TON of Python add-ons for vim. I have no idea which is good, as I don't regularly use python.

  37. ryan.richards@mindonstatic.com said 2 days later:

    Yes VIM rocks. I use vim for everything. HOWEVER, I just started playing a new editor called e-textmate. Its AWESOME. It's supposed to be a textmate close and even uses some of the textmate bundles. Its not free but only costs about $30. Its missing vi keybindings but you can add them or wait (they say its coming ). Check it out at http://e-texteditor.com. For those chained to windows you will be happy to know it HEAVILY integrates with Cygwin and actually requires it.

    Ryan

  38. Guy Naor said 2 days later:

    Ryan, e-texteditor.com looks nice, but I'm on Linux, so it won't work for me...

    Glad to see there'll be some TextMate solutions for us not MacOS users.

  39. Antonio said 2 days later:

    Hi,

    I'm also a vim fan :-)

    Now, what about NetBeans?

    There's a vi plugin for NetBeans . I've been using it for a month or so and, although not as potent as VIM, I must admit that it has increased my productivity by a factor of ten.

    Furthermore, NetBeans Ruby support is on the make!!

    Finally, the NetBeans Community is asking Eclipse users for feed back on new editor features.

    You can see examples of feedback and ask for your favourite features to be added to the next version of NetBeans.

    Cheers,

    Antonio

  40. meek said 2 days later:

    As an ex-VIM user, I recommend Scribes on Linux. It provides most of the essential features of VIM, without the hideous user interface and ridiculous learning curve. Within an hour, you'd be more productive in Scribes than you'll ever be in VIM.

    Flash Demo: http://scribes.sf.net/demo.htm

  41. Harvey Sugar said 2 days later:

    I've been programming in several languages for quite a while and have used several editors and IDEs. I don't do Ruby (yet) but for Java and C++, I use Eclipse for compile/debug and fixing little compile errors. BUT I still do almost all my code entry and major editing with vim. Sure it's cryptic but you won't find anything as responsive and powerful as vim and you can pretty much depend on finding a version that runs on any OS that you may be using.

Comments are disabled

Subscribe to The Dev Blog