[Executives' summary (in case any executive uses Vim) - get this updated pylint.vim for compatibility with pylint 0.24.0 changes]
Integrating Python code checker into Vim is really cool. It lets Vim provide (relatively) quick feedback on your code, be it a conventions warning or syntax error. That, in my opinion, increases coding productivity slightly.
The problem is, that configuring the vim-pylint integration is hell. for two reasons mainly:
- Doing it manually requires understanding of the unpleasant errorformat syntax and some other vim tricks.
- No good zero-setup plugin is available: official pylint.vim is unmaintained. I used to use this fork, but its not really active anymore.
Specifically, since I upgraded to latest pylint (0.24.0), Vim stopped showing pylint's hints. That's because pylint's output was modified to contain the column number as well.
I've re-forked it, and updated it to support pylint 0.24.0. Note that it will probably fail with older versions. Please try it and send feedback (you can comment this post if easier).
Exuberant ctags is a cool, language-agnostic tool for creating tag files for your source code. Nice editors such as Vim, could use these tag files to implement the much needed 'jump to definition' feature.
Ctags is awesome, it supports Python, and is supported by Vim. It seems that the world is perfect and there's no reason to write a post about configuring it. Well... almost.
ctags has a little downside when using Python: it recognizes import lines as a definition, at least as of ctags v5.8. No need to explain why it's annoying in most cases. After 2 years of suffering, I've found it's possible to overcome this simply by adding the --python-kinds=-i option to the command line, or better: to ~/.ctags.
And just to make it complete, a quick cookbook style for setting everything up and using:
- Install ctags
e.g. aptitude install exuberant-ctags
- Configure ctags.
Add to ~/.ctags the following, one option per line:
- optional: --exclude=<partial names of bad files/directories>. e.g. --exclude=*/build/* to exclude all files inside 'build/' directories
- Add a cron to rebuild tags, for instance:
1 * * * * ctags -R -o ~/mytags ~/src
- Configure vim:
add to ~/.vimrc: :set tags=~/mytags
- Use Vim:
- vim -t <tag name> to open vim straight on the tag
- Ctrl+] to jump to tag when over a word
- Ctrl+T to pop back
- :tselect or :stselect to open
- :tnext, :tprev to go to next/prev tag finding
- :help tags for more 🙂
In perl regexp syntax, \b (b means bareword) can be used for searching a whole word. I.e. \btext\b:
Will match: text, @text, <space here>text!, etc
Won't match: textile, mytext.
I've been looking for a similar feature in vim for months, with no luck, until today. I've found out how to do that, the syntax is simply \<text\>. Works for search mode (/,?), substitute (:s), and probably for other modes as well.
Actually that's what the #, * keys do (search for the under-the-cursor whole word), and that's how I found that out.
I also wrote one, with the most useful commands that I know..
check it out..