Get infected by vim
So, if you have made the correct life changing decision (o yes, that's right - please ignore the crazies who suggested you should use emacs :-p) and decided that vim is going to be the weapon (aka code editor) of choice, this little post will explain how you can organize your vim plugins cleanly so that you will not have a "vim functionality maintenance headache" in the many good years to come.
Traditionally, you customize your vim editor by means of settings and scripts placed in your .vimrc file as well as your .vim directory.
calvin$ cd ~
calvin$ ls -la
drwxr-xr-x@ 19 calvin staff 646 Sep 4 23:41 .vim
-rw-r--r-- 1 calvin staff 22010 Sep 5 12:45 .viminfo
-rwxrwxrwx 1 calvin staff 25 Jul 31 20:15 .vimrc
calvin$ ls -la .vim
total 120
drwxr-xr-x@ 19 calvin staff 646 Sep 4 23:41 .
drwxr-xr-x+ 78 calvin staff 2652 Sep 5 12:54 ..
-rw-r--r-- 1 calvin staff 105 Sep 4 23:41 .netrwhist
drwxrwxrwx 3 calvin staff 102 Jul 31 18:26 after
drwxrwxrwx 5 calvin staff 170 Aug 27 00:57 autoload
drwxr-xr-x@ 7 calvin staff 238 Jul 31 18:26 colors
drwxr-xr-x@ 8 calvin staff 272 Aug 27 00:57 doc
drwxr-xr-x@ 4 calvin staff 136 Apr 10 2010 ftplugin
drwxr-xr-x@ 5 calvin staff 170 Feb 8 2010 indent
drwxrwxrwx 5 calvin staff 170 Jul 31 18:26 lib
drwxr-xr-x@ 13 calvin staff 442 Aug 27 09:57 plugin
drwxr-xr-x@ 10 calvin staff 340 Aug 27 00:58 syntax
drwxrwxrwx 6 calvin staff 204 Aug 27 01:00 tests
Unfortunately, this approach implies that each vim plugin you choose to "install" requires that you manually find that plugin's "ftplugin files" and place it in your ~/.vim/ftplugin directory; that plugin's "plugin files" and place it in your ~/.vim/plugin directory.
Although this is a one-time affair when you first install a specific vim plugin and its directory specific files, the problem begins when it's time for you to update/upgrade your plugin... imagine having 10s of vim plugins with its respective files placed in different directories and you have to track them down after last installing them 1 year ago and you no longer remember where's where.
Get ready to be infected by Pathogen
Fortunately for us vim users, we have some pretty talented people in the vim community. Tim Pope has written the perfect vim plugin to rule them all.
Hop right over to https://github.com/tpope/vim-pathogen, follow the install instructions and from now on, ALL your other vim plugins can be housed in a directory structure like this
~/ .vim
|____ autoload
| |_________ pathogen.vim
|____ bundle
|__________ yourotherplugin01
| |_____ plugin
| |_____ autoload
| |_____ ...
|
|__________ yourotherplugin02
|_____ plugin
|_____ autoload
|_____ ...
In this manner, each of your plugins are completely isolated in its own directory. That means that when it is time to update/upgrade a specific plugin, it's as simple as doing a git pull (if you are using git to make that specific plugin of course).
And of course, if you are using .vim as a .git repository and each vim plugin is its own nested git repository, git submodules will make your vim update as easy as a walk in the park.
Elegance! That never fails to turn me on :-))
Category: vim



Discussion
Excellent tip on VIM!
Thanks Raymond! Just spreading the love ;-)
Leave a Comment :
Leave a Comment