Plugin spotlight – Syntastic

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.

If you're using vim-plug, you can install Syntastic by adding Plug 'vim-syntastic/syntastic' to your .vimrc file and running :w | source $MYVIMRC | PlugInstall.

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:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.199.162