VIM: Making it Work on Leopard

I am a Linux user at heart and the Leopard command line is very bland compared to what I am used to. The default vim is also pretty bland and unimpressive. I thought I would share a few of the settings I have found or plundered from Linux installations in order to make vim more usable.

This can go in your .vimrc or in a global location such as /usr/share/vim/vimrc. I would be interested in what other command line and vim users do to improve Leopard. I have various aliases in order to add colour to various commands too.

set nocompatible " Use Vim defaults
set bs=2 " backspacing over everything in insert mode
set ai " Auto indenting
set history=100 " keep 100 lines of history
set ruler " show the cursor position

set viminfo='20,\"200 " keep a .viminfo file

syntax on " syntax highlighting
set hlsearch " highlight the last searched term

filetype plugin on " use the file type plugins

" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

You might want to install gvim

You might want to install gvim. This is easy within fink. With GTK+2 you can use an appropriate theme (like glossy P, also in fink) that makes it look very aqua-like).

vim and os x

It's not difficult to install the latest and greatest vim, though Leopard shipped with a reasonably recent release. In fact, compiling vim from source on OS X is just like on any Linux distro. In either case I'd write a '.vimrc' file.

Additionally, I find the OS X command line better than the Linux one, in the sense that Apple has included a large number of OS X specific commands (like open and mdfind, mdls, etc) that are pretty nice.

In fact, as of Tiger or Panther, arguably, OS X has been mature enough to render a separate Linux distribution completely obsolete, for me.

Edit: and if you want a GUI version of vim, MacVim is quite a nice project these days:

http://code.google.com/p/macvim/

macvim is nice

Thanks for the tips - I hadn't heard of macvim but it is pretty nice. I think I will still be using Linux quite a bit too and find it easier to get some things done. I was surprised by how colourless the default terminal is in its output, I guess I have been spoiled over the years. I would like to set up some reasonable system wide defaults as many Linux distros do.

I don't think I could have coped with just Tiger but Leopard seems to have a lot more of the features I have become accustomed to and expect. I do admit to logging into KDE or OS X and opening three or four terminals though! So not sure how much I will really use macvim even.

Integrating MacVim into OS X

If you do start using MacVim (or Vim for OS X, the traditional GVim), you may find these two pages useful:

The former page gives you launchers that make sure that Vim is using the correct PATH (i.e., they launch vim from a bash login (which you could change to tcsh, if you prefer)). They also make sure Vim shows up in your "Open With" menus for lots of different types of text documents.

The latter page shows how to integrate Vim with Skim, which is probably the nicest PDF viewer available for any operating system. If you build LaTeX documents with source specials (i.e., you use PDFsync), then Skim can call Vim to drop you at the particular spot in your source code corresponding to the rendered PDF location. Note that Skim can spell check a PDF, which is a feature that dovetails nicely into PDFsync support.

Of course, you could also integrate inverse PDF searches into xdvi. A Linux user should appreciate that.

--
Ted Pavlic
http://www.tedpavlic.com/
http://phaseportrait.blogspot.com/