Friday 27 April 2012

VIM Pathogen & Disabling Arrow Keys

VIM can handle plugins by default without any third party intervention but in my limited experience it can be a little confusing and messy. Enter Pathogen, a plugin that makes it “super easy to install plugins and runtime files in their own private directories.”. Normally I wouldn’t go in for super easy when I’m trying to learn something because you normally end up with half the picture. In this case however, I’m going to allow myself to use Pathogen because good package managers are glorious things when they work. Here’s looking at you pip, homebrew and npm.

Installing Pathogen

There are full instructions on how to install pathogen on it’s Github page, but for the sake of clarity here’s what I did to install it –

 cd ~/src git clone mkdir -p ~/.vim/autoload ~/.vim/bundle mv vim-pathogen/autoload/pathogen.vim ~/.vim/autoload 


Incase you didn’t know, the ~/.vimrc file is where you store your run commands for vim. So now that pathogen is installed, I have to create the ~/.vimrc file and call pathogen in it to set up my VIM environment. This is how my ~/.vimrc looks –

 call pathogen#infect() syntax on filetype plugin indent on 

Now if you open up your ~/.vimrc file (vim ~/.vimrc) using vim you should see no errors. If you see something like the below error then make sure that you’ve put the pathogen.vim plugin into the ~/.vim/autoload/ directory.

 E117: Unknown function: pathogen#infect 

Disable Arrow Keys

I’ve became accustomed to using the arrow keys for moving around text documents and VIM will let you get away with this, but I want to get used to using hjkl for moving around. I know at first I’ll find this infuriating, but I hope that eventually I’ll come out of the other side a better VIM user. Here’s how I disabled the arrow keys in my ~/.vimrc file

 noremap   "" noremap!   noremap   "" noremap!   noremap   "" noremap!   noremap   "" noremap!   


In day two of my VIM quest I’ve installed pathogen and started off my ~/.vimrc file. I’ve also disabled the arrow keys to force myself to use the native method of moving around a file.

I’m ready to start getting my hands dirty.