How to use Syntastic as syntax checker for Vim

Vim is not an IDE, but there are some really cool plugins written for Vim that make it almost an IDE. One of the basic needs of a programmer is to know if the code he has typed is syntactically correct, without having to compile or interpret it. This is the job of a syntax checker. IDEs like Visual Studio highlight places in the code with wrong syntax with red squiggles.

Syntastic is a Vim plugin that brings syntax checking to Vim. It can be installed easily for Pathogen by cloning its Github repository. Syntastic relies on external syntax checkers for different languages. These syntax checkers need to be installed and Syntastic needs to be configured to use them. This information can be found on the Github page.

For example, to enable syntax checking for Python, I first installed the pyflakes syntax checker program for Python. After that I opened the syntax_checkers/python.vim file and set this as the syntax checker.

Now when I finish typing some Python code and save it, Syntastic runs the program through pyflakes and highlights lines with syntax errors in the leftmost column that is used by Vim for signs. On moving the cursor to the erroneous line, the error is displayed at the bottom of Vim. Pretty cool, isn’t it?😉

Tried with: Vim 7.3 and Ubuntu 12.04 LTS

One thought on “How to use Syntastic as syntax checker for Vim”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s