I do not want to install another plugin, like pylint.vim,
And today, I decide to use vim edit python instead of pydev which is a eclipse plugin. But I got issues.
I have add this in my vimrc
autocmd BufWritePost *.py !pylint <afile>
but pylint does not contains filename in output
************* Module mymodule
E: 22: invalid syntax
shell return 2
so it can not jump to the line 22 , so I use sed change the output
autocmd BufWritePost *.py !pylint <afile> | sed 's/^\(\w*\):\s*\([0-9]\+\)/<afile>:\2: \1: /g'
it returns:
mymodule.py:22: E: : invalid syntax
but without shell return 2 by vim. so it still can't jump to that line. vim consider it as compile successfully
========================= new comment =========== http://stackoverflow.com/questions/1766336/call-a-function-in-vims-autocmd-command
I think maybe I should use make command and set makeprg, so I use below config
autocmd FileType python let &makeprg='pylint <afile> | sed s/^\(\w*\):\s*\([0-9]\+\)/<afile>:\2: \1: /g'
autocmd BufWritePost *.py make
when I save, vim returns:
************* Module count
E: 3: invalid syntax
(1 of 2): ************* Module count
Error detected while processing BufWritePost Auto commands for "*.py":
E492: Not an editor command: sed s/^\(\w*\):\s*\([0-9]\+\)/<afile>:\2:
\1: /g