Syntastic is the go-to plugin when it comes to syntax checking. It supports over 100 languages (and can be extended with smaller syntax checker plugins). Syntastic is available from https://github.com/vim-syntastic/syntastic.
Syntastic does not provide newbie-friendly defaults, so you may want to have the following in your .vimrc file:
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_pylint_exe = 'pylint3'
Now, as long as you have a Python syntax checker (such as Pylint) installed on your system, you will see the following when you open a Python file:
There are a few things going on here, from top to bottom:
- Lines with syntactic errors are highlighted with >>
- Offending characters or strings are highlighted as well
- A location list is open, listing everything wrong with the current file
- A status line is displaying the error on a currently open line
Since this is a regular location list, you can use the usual location list shortcuts to navigate (for example, :lnext or :lprevious).
If you were to fix the error, the syntax error list updates as soon as you save the file: