1. Installing pathogen
Since Syntastic uses another Vim plug-in called pathogen, you need to install pathogen first:
mkdir -p ~/.vim/autoload ~/.vim/bundle;
curl -so ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
Now add this to your .vimrc file:
I added it at the end, and it seems to work fine.
2. Installing Syntastic
To actually install Syntastic we just need to place its code in the ~/.vim/bundle/syntastic directory. This can be done by simply changing to that directory and cloning it, as described by Syntastic’s installation instructions:
git clone https://github.com/scrooloose/syntastic.git
Also available in submodule flavour
But since my whole .vim directory is git-versioned, I thought it would be more elegant to add it as a git submodule. That way, I can get Vim configured to my tastes in a new machine in a couple of minutes!
So this is how I did it:
git submodule add https://github.com/scrooloose/syntastic.git bundle/syntastic
Close Vim and reopen it and try typing this to test it works:
As Syntastic manual reads, if you get an error at this point, something went wrong. In my case was fine so I moved on to installing JSHint.
3. Installing JSHint
sudo npm install -g jshint
Why sudo? Because we’re telling npm to make a global (-g) installation, so that the jshint command line tool is available and in the path. (NOTE: If you know of a better way so that it’s installed for the current user only, let me know in the comments. Thanks!)
At this point maybe you need to close and open again Vim, but other than that, JSHint should be responding to Syntastic pleas for help each time you save a JS file, and you’ll be getting a little bit of help right in your editor; every time you make an error, there will be a couple of arrows mercilessly pointing to your error. And they won’t go away until you fix them 😉
Shamelessly hotlinking Syntastic’s screenshot: