rc3.org

Strong opinions, weakly held

Back in the saddle with Vim

I’ve been a vi user for many, many years. In fact, I used to program in C on a MUD using ed (vi is the fancy version of ed). However, it’s been a long time since I used vi as my editor of choice for development work. I use it for hacking scripts, editing files on servers, and general purpose text editing in a terminal window, but most of the time I use Eclipse for Java and TextMate for pretty much everything else.

A lot of people in the Rails community have migrated over to vim (and MacVim) in recent years, and I know there’s a very active community of programmers who are working hard to make it a better tool for developers. Anyway, I wanted to try out the Solarized color scheme people were talking about and Vim looked like the best option, so I decided to dive in, at least for Rails development.

I’ve been really impressed. Tim Pope’s rails.vim library for Rails developers is really, really good. The navigations features in particular are worth the price of entry. Then there’s the inherent goodness of Vim itself. Vim is difficult to approach initially, but it’s an incredibly powerful tool in the hands of someone who really knows how to use it. Even though I have been using it for a long time, I don’t really consider myself to be a Vim power user by any stretch of the imagination, because I’ve mainly used it to edit small files, one at a time.

Using Vim for project work is completely different, and that’s the area where my Vim skills need work. TextMate provides you with a file drawer with all of the files in your project, easy to use search across all the files in a project, and the ability to easily open multiple files in a tabbed editor and switch between them. The next step is to learn the tricks to accomplish the same things using Vim. Anyone seen a good tutorial?

Update: Just for fun, here’s my .vimrc.

13 Comments

  1. NERDtree (https://github.com/scrooloose/nerdtree) does the file drawer thing for Vim, but honestly since I’ve started using FuzzyFinder (http://www.vim.org/scripts/script.php?script_id=1984), I hardly ever use NERDtree anymore.

    Also, before you try either, install Pathogen (https://github.com/tpope/vim-pathogen). It will change your life.

  2. I remember debating with a fellow student which editor was better: vi or XEDIT (editor on IBM mainframes). In 1985. XEDIT won.

    Of course I always end up using vi when ssh’ing into servers, but pretty rarely use it on my desktop. Haven’t been frustrated enough with BBEdit to use vi as my “main” editor.

    I’m curious why Rails-istas have moved from TextMate to vim. Something wrong with TextMate? Folks doing a lot of work on *nix?

  3. I have already grabbed Pathogen. I confess that I was disinclined to install NERDtree because the capitalization of the name kind of bugs me.

  4. I’m quite partial to vim in combination with GNU Screen: http://jmcpherson.org/screen.html

  5. I generally use cscope with vim. A couple years ago using ruby I also had some kind of tags generator (exuberant ctags supports ruby, I believe). Cscope isn’t as fabulous for Ruby as it is for c/c++/java, but it’s still pretty awesome, imho.

    Anyways, with vim+cscope+screen I rarely have to move my hand to the mouse when editing.

  6. s/fancy version of ed/fancy version of ex, which is in turn the fancy version of ed/

  7. I tried out solarized too and I couldn’t seem to get into it. I’m using vividchalk –

    http://bit.ly/dZ3Vf5

    Tim Pope made it (https://github.com/tpope/vim-vividchalk). Perhaps I just got used to it.

  8. Janus (https://github.com/carlhuda/janus) is a great set of vim plugins and customizations. Even if you don’t want to use it as a starting point it’s a solid list of things to look in to.

    Especially of note for you, it includes a plugin called Command-T which provides the same file search behaviour to vim as that key sequence starts in TextMate.

  9. Patrick, I’ve never been a TextMate user but my impression is that many people are getting frustrated with the lack of updates, and by moving to vim the community is creating all the things they wish TextMate could do.

  10. It’s easy now to have a copy of your production environment (or something close to it) running in a virtual machine on your laptop where makes sense to just use vim in a checkout of your source tree there, instead of juggling versions of Ruby/Python/ModPerl on your Mac.

    My only hassle was installing debian build tools and making vim 7.3 from source.

    If you’re doing any JavaScript work, I recommend the vim plugin for JSHint: https://github.com/wookiehangover/jshint.vim

  11. Plain old :b(uffer) is great for navigating files that you have open. Just type in :b and any part of the filename and hit tab. With that and :sp(litscreen) you are set!

  12. All good recommendations. I’d start with Steve’s post below. He goes over a bunch of advanced vim techniques and plugins he uses. I think his focus is a little more on C than ruby but the lessons are similar.

    http://stevelosh.com/blog/2010/09/coming-home-to-vim/

    Most of the good and maintained vim plugins have migrated to github.

  13. I wrote a Textmate to VIM guide where I detail how to do 110 Textmate features in VIM. I think it would be a great resource to add to this page. http://www.jackkinsella.ie/2011/09/05/textmate-to-vim.html

Leave a Reply

Your email address will not be published.

*

© 2024 rc3.org

Theme by Anders NorenUp ↑