Category Archives: Vim

Check out the vim-cocoa branch of MacVim

There is an Intel binary here:

Once thing I noticed was that the startup time was good. The tabs drawer is missing, but seems to be a nice Cocoa port of Vim.


Enabling folding in Vim, especially for Ruby

I was originally going to release my .vimrc on the blog, but I’m in the process of repairing it up right now–so it might just confuse people. I will release it at a later time when it is stable(I cleaned it up to get rid of a problem I was having after creaing the ShowMeDo videos, in which i inadvertently destroyed the folding setup). Meanwhile, most of my file is derived from Amir Salihafendic’s vimrc file, available here.

A couple of things I changed from his suggestions:

  1. (Mac OS X only) I put the helper directory contents directly in the package contents
  2. (possibly Mac OS X only)I turned off lazy redraw

Meanwhile, I was able to recover most of my folding stuff with the following commands. here is how folding should work(put this in your .vimrc–without the numbers of course):

  1. set foldenable
  2. set foldmethod=indent
  3. set foldlevel=1

That last line depends on your shiftwidth, which you can set by set shiftwidth=2, for example. For a shiftwidth of 2, set foldlevel=1 seems to work fine. Also, for some reason, even though I enabled folding with the first command above, I still have to type in zC in command mode to see the folding.

Hope this helps.

Vim indenting tip

:set shiftwidth=2

Best Vim tip

The one I use the most from (using it continuously for 6 months):In command mode, type in exactly:

:imap jj <Esc>

and hit Enter.

This lets you enter command mode by pressing jj instead of the trips to the Escape key(you can save that line in your vimrc as well).

Getting rid of ^M in Vim

If you work in multiple environments, you might open the same document using a DOS file format(Windows) or a unix file format, you might see your document littered with ^M. Don’t panic, a simple fix, in command mode, is:

:%s/\r//g (courtesy of Vim online).