Using Vim with Pathogen
July 18, 2011 § 7 Comments
Vim is my editor of choice. Vim is everywhere and has hundreds of plugins to allow you to do pretty much anything a text editor can possibly do.
The problem is, setting up Vim to use plugins is not the simplest thing to do. Enter Pathogen.
Pathogen is written by Vim plugin guru Tim Pope, it lets you isolate plugin scripts under their own directories. This means easy installs, uninistalls and upgrades.
Here’s a walk through about how to get this up and running:
I always like to start things from a clean slate, so firstly backup anything you already have:
mv ~/.vimrc ~/.vimrc.bak mv ~/.vim/ ~/.vimbak/
Next create a brand new .vim directory and download pathogen:
mkdir -p ~/.vim/autoload mkdir -p ~/.vim/bundle cd ~/.vim/autoload curl https://github.com/tpope/vim-pathogen/raw/master/autoload/pathogen.vim > pathogen.vim
Now create a new ~/.vimrc and put the following lines at the top:
" Pathogen filetype off " Pathogen needs to run before plugin indent on call pathogen#runtime_append_all_bundles() call pathogen#helptags() " generate helptags for everything in 'runtimepath' filetype plugin indent on
That’s pretty much it.
Now for the payoff – git powered plugin management. As seems to be the case with most code these days, many vim plugins are hosted on Github
Let’s walk through installing the popular NERDTree plugin. This plugin gives Vim a Textmate style project drawer:
cd ~/.vim/bundle git clone git://github.com/scrooloose/nerdtree.git
restart vim, and boom NerdTree is installed, do a :NERDTreeToggle to hide and show the project drawer. To uninstall just delete the cloned repo:
rm -Rf ~/.vim/bundle/nerdtree
Simples.
Here are some of the plugins I like:
-
Essential if you’re a Rails developer, allows switching between files, autocompletion, refactoring, and lots more.
git clone git://github.com/tpope/vim-rails.git
-
Command-T Leader t (usually \t) for quickly finding files.
git clone git://git.wincent.com/command-t.git
-
snipmate.vim TextMate-style snippets in Vim: type def and a Ruby method block gets created.
git clone git://github.com/msanders/snipmate.vim.git
-
vividchalk.vim A colorscheme strangely reminiscent of Vibrant Ink for a certain OS X editor.
git clone git://github.com/tpope/vim-vividchalk.git
Personally I like to keep my dotfiles (including vim config) in a git repo. I add vim plugins as git submodules. For example, I would add the essential rails-vim plugin like so:
$ git submodule add https://github.com/tpope/vim-rails.git ~/.vim/bundle/vim-rails
This makes it easy to update plugins later. You can read all about submodules here: http://kernel.org/pub/software/scm/git/docs/git-submodule.html
Hmm, tried this today… added the nerdtree plugin from git, just like you wrote. but starting up vim, nerdtree is NOT there.
[…] [1] Pathogen github site [2] logicalfriday.com post […]
Thank you for posting this it really helped but the url for pathogen.vim does not work anymore. The one that worked for me is
https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
Please update when you get a chance :)
Thank you this was very usefull
I am having no success at all with pligins . I have tried many different methods, used the commands that were suggested. No Success !
I am running linux mint 15 and Ubuntu 13.10 and windows 8. I am new to vim.
to use Pathogen in vim 7.4, what do I type where to download plugins????? I assume your description of use if very informative to people EXPERIENCED in using it!! I am not an really getting fed up trying to figure out what the heck you’re talking about!