{"id":293,"date":"2011-02-06T13:48:41","date_gmt":"2011-02-06T10:48:41","guid":{"rendered":"http:\/\/www.held.org.il\/blog\/?p=293"},"modified":"2012-12-15T23:58:05","modified_gmt":"2012-12-15T20:58:05","slug":"configuring-ctags-for-python-and-vim","status":"publish","type":"post","link":"http:\/\/www.held.org.il\/blog\/2011\/02\/configuring-ctags-for-python-and-vim\/","title":{"rendered":"Configuring ctags for Python and Vim"},"content":{"rendered":"<p>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.<\/p>\n<p>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.<\/p>\n<p>ctags has a little downside when using Python: it recognizes <strong>import lines<\/strong> 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\u00c2\u00a0<em><strong>--python-kinds=-i <\/strong><\/em>option to the command line, or better: to ~\/.ctags.<\/p>\n<p>And just to make it complete, a quick cookbook style for setting everything up and using:<\/p>\n<ol>\n<li><strong>Install ctags<\/strong><br \/>\ne.g. <em>aptitude install exuberant-ctags<\/em><\/li>\n<li><strong>Configure<\/strong> <strong>ctags<\/strong>.<br \/>\nAdd to ~\/.ctags the following, one option per line:<\/p>\n<ol>\n<li>--python-kinds=-i<\/li>\n<li>optional: --exclude=&lt;partial names of bad files\/directories&gt;. e.g. <em>--exclude=*\/build\/*<\/em> to exclude all files inside 'build\/' directories<\/li>\n<\/ol>\n<\/li>\n<li><strong>Add a cron <\/strong>to rebuild tags, for instance:<br \/>\n1 * * * * ctags -R -o ~\/mytags ~\/src<\/li>\n<li><strong>Configure vim<\/strong>:<br \/>\nadd to ~\/.vimrc: :set tags=~\/mytags<\/li>\n<li><strong>Use Vim<\/strong>:\n<ol>\n<li>vim -t &lt;tag name&gt; to open vim straight on the tag<\/li>\n<li>Ctrl+] to jump to tag when over a word<\/li>\n<li>Ctrl+T to pop back<\/li>\n<li>:tselect or :stselect to open<\/li>\n<li>:tnext, :tprev to go to next\/prev tag finding<\/li>\n<li>:help tags for more \ud83d\ude42<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8216;jump to definition&#8217; feature. Ctags is awesome, it supports Python, and is supported by Vim. It seems that the world is perfect and there&#8217;s no [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,14],"tags":[148,93,124],"_links":{"self":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/293"}],"collection":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":0,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/293\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/media?parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/categories?post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/tags?post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}