vim! it's slim and trim. here's why it wins...

by Derek Sivers

Related link: http://www.vim.org/



Doing a new project in Rails, I started using vim when putting it together, then a couple weeks went by, and I never got out of vim!

I used to use GUI-based editors with syntax highlighting, code hints and such - until I found that vim can do all of that! Once I figured out how to make it automatically close all my parens, braces, and brackets, I was sold.

Here's my favorite .vimrc thing that helped....

Put this in ~.vimrc

:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf


The other thing that helped a lot was konsole. I like to full-screen all my terminal windows. Never fond of having lots of little boxes floating around. So, when in a Rails dev-mood, I open up a tab at the bottom for EACH of these:
  • project
  • model
  • view
  • controller
  • lang
  • database (pg/mysql console)
  • Rails/ActiveRecord console
  • misc
  • log


I just [SHIFT]-arrow back-n-forth between them, each one taking the full screen, and getting my full attention while working.

11 Comments

merlyn
2005-07-24 20:32:53
Cool, vim is getting in 2005 what Emacs had in 1995
About time. Only a decade behind. {grin}
aristotle
2005-07-24 22:37:54
Cool, vim is getting in 2005 what Emacs had in 1995
Vim has had Perl built in (as a compile-time option) for a couple years now, Randall. Does emacs do that? :)
aristotle
2005-07-24 22:43:32
Editorial correction request
You forgot to turn < into &lt;, so your <ESC>, <c-r> and <Right> are treated as tags instead of showing up on the page.
wbk
2005-07-25 01:11:35
Cool, vim is getting in 2005 what Emacs had in 1995
Cool, Emacs got in 1995 what TECO had in 1963. Zing!
breskeby
2005-07-25 01:51:27
like to add a trackback
hello, by the way, what is the trackback url of articles published by oreillynet.com?


brs

dereksivers
2005-07-25 08:20:52
Editorial correction request
Thanks aristotle - fixed.
dereksivers
2005-07-25 08:21:40
like to add a trackback
I believe it's this page it's on : http://www.oreillynet.com/pub/wlg/7430
bingalls
2005-07-26 06:28:38
Cool, vim is getting in 2005 what Emacs had in 1995
Hm? I thought vim was written only in C, and depended only on C libraries.
If the integrated Perl Debugger and Compiler in Emacs are not good enough for you, there is Perlmacs.


Extoll, don't troll!
Vim is even sweeter with http://cream.sourceforge.net/


Since you mentioned Emacs, a shameless plug for the equivalent in Emacs to Cream:
http://emacro.sourceforge.net/
Avoid the 2005-1beta, until you know how to use it, or unless you are upgrading.

aristotle
2005-07-26 14:22:39
Cool, vim is getting in 2005 what Emacs had in 1995
Well, you think wrong then. Or maybe not entirely, as I did say compile-time option. But Vim has been offering the choice of an embedded Perl, Python and Ruby when you build it for quite some time now. (Yes, even all three at once; that is, if you are fond of a binary much heavier than Emacs ever was.)


I’ve actually written Gtk2-Perl scripts that run from within gvim. It’s pretty neat.

sporkmonger
2005-08-01 16:04:22
wooo, another editor discussion
Personally, I gotta go with TextMate. Of course, it is OS X only, but given that I'm on a Mac, it's hardly a barrier to adoption for me. It's easily the most user-friendly of the beefy text editor breed, and unsurprisingly, probably also the prettiest. It doesn't have all the bells and whistles of vim or emacs, but to be honest, I rarely use most of those gizmos anyhow.


And of course, it plays quite nicely with Ruby.

merlyn
2005-08-18 20:31:55
Cool, vim is getting in 2005 what Emacs had in 1995
Emacs has had that since around 2000, according to http://search.cpan.org/~jtobey/Emacs-PerlmacsPatch-0.16/


That's a bit more than "a couple of years".