Skip to content

Instantly share code, notes, and snippets.

@jraines
Created May 1, 2011 20:03
Show Gist options
  • Save jraines/950811 to your computer and use it in GitHub Desktop.
Save jraines/950811 to your computer and use it in GitHub Desktop.
Macvim & Janus

##Intro

Janus is a "basic distribution of vim plugins and tools intended to be run on top of the latest MacVIM snapshot." It is maintained by Yehuda Katz and Carl Lerche.

I recently whinged on Twitter that all I really want is vim with TextMate's Command-T go-to-file functionality and some efficient visual tab/buffer navigation. Turns out MacVim + Janus, with just a few tweaks, is all that and more.

Installing Janus

Follow the installation instructions on the git page

Some repos may not be found, causing the rake to fail. Delete these from the Rakefile or find the repo and edit the Rakefile

The rake may also fail when trying to install the build the native extensions of the Command-T gem. You will need to find the folder on your system and symlink it to the one the Rakefile is trying to use. On my system:

ln -s /Library/Ruby/Gems/1.8/gems/command-t-1.2.1/ruby/command-t/ ruby/command-t

Installing Command-T vim plugin

At this point the Command-T plugin will not work in Vim. You need to open the "vimball" and source it. [https://wincent.com/products/command-t](Go to the Command-T page and follow the instructions.)

Sweet! Now I have my beloved Command-T functionality from Textmate in vim.

Installing Ack

Another feature from Textmate that is useful, though horribly slow, is Find In Project. There is an Ack based replacement .bundle for that called Ackmate, and Janus also uses Ack for Find-in-Project, which is conveniently also mapped to CMD-SHFT-F.

cd ~
curl http://betterthangrep.com/ack-standalone > ack
sudo chmod 0755 ack
sudo mv ack /usr/local/bin   

Boom! Find in project now works

Installing Taglist (go to symbol)

First, install Exuberant Ctags. You may need to delete your version of ctags which shipped with the OS.

sudo rm /usr/bin/ctags
curl -O http://superb-west.dl.sourceforge.net/sourceforge/ctags/ctags-5.7.tar.gz
tar xzvf ctags-5.7.tar.gz
cd ctags-5.7
./configure
make
sudo make install

Edit your ~/.gvimrc to have Taglist gain focus when you open it, and map CMD-SHFT-M to :TList

map <D-M> :Tlist<CR>
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Close_On_Select = 1
let Tlist_Compact_Format = 1
let Tlist_Show_One_File = 1

Useful commands for Rails

:RunSpec

Run the current Spec

:RunSpecs

Run all the specs. Actually haven't found this useful yet -- where's the summary?

NERDTree

I like to keep MacVim open on NERDtree even if I've closed the last non-NERDtree buffer, so I comment out this line in .gvimrc

" autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()

Toggle NERDTree project drawer

\n

NERDTree: Create file in highlighed directory

  • Press m then select a

NERDTree: rename file

  • Press m then select m

Updating

rake upgrade

##Tab oriented workflow

  • Open files in new tabs

    • From NERDTree
    t
    
    • From Command-T
    <C-t>
    
  • Open file as a vertical split in current tab window

    • From NERDTree
    s
    
    • From Command-T
    <C-v>
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment