<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Alain M. Lafon &#187; vimpdb</title> <atom:link href="http://blog.dispatched.ch/tag/vimpdb/feed/" rel="self" type="application/rss+xml" /><link>http://blog.dispatched.ch</link> <description>code, life and struggles thereof</description> <lastBuildDate>Mon, 16 Jan 2012 13:44:17 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>VIM as Python IDE</title><link>http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/</link> <comments>http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/#comments</comments> <pubDate>Sat, 23 May 2009 23:04:59 +0000</pubDate> <dc:creator>Alain M. Lafon</dc:creator> <category><![CDATA[articles]]></category> <category><![CDATA[coding]]></category> <category><![CDATA[ctags]]></category> <category><![CDATA[exuberant ctags]]></category> <category><![CDATA[ide]]></category> <category><![CDATA[minibuf]]></category> <category><![CDATA[omni completion]]></category> <category><![CDATA[pep 8]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[python]]></category> <category><![CDATA[python ide]]></category> <category><![CDATA[taglist]]></category> <category><![CDATA[tasklist]]></category> <category><![CDATA[tutorial]]></category> <category><![CDATA[vi]]></category> <category><![CDATA[vim]]></category> <category><![CDATA[vimpdb]]></category> <category><![CDATA[walkthrough]]></category> <guid
isPermaLink="false">http://blog.dispatched.ch/?p=777</guid> <description><![CDATA[Finding the perfect IDE for Python isn&#8217;t an easy feat. There are a great many to chose from, but even though some of them offer really nifty features, I can&#8217;t help myself but feel attracted to VIM anyway. I feel that no IDE accomplishes the task of giving the comfort of complete power over the [...]]]></description> <content:encoded><![CDATA[<p>Finding the perfect IDE for Python isn&#8217;t an easy feat. There are a great many to chose from, but even though some of them offer really nifty features, I can&#8217;t help myself but feel attracted to VIM anyway. I feel that no IDE accomplishes the task of giving the comfort of complete power over the code &#8211; something is always missing out. This is why I always come back to using IDLE and VIM. Those two seem to be best companions when doing some quick and agile hacking &#8211; but when it comes to managing bigger and longer term projects, this combo needs some tweaking. But when it&#8217;s done, VIM will be a powerful IDE for Python &#8211; including code completion(with pydoc display), graphical debugging, task-management and a project view.</p><p>This is where we are going:</p><p
style="text-align: center;"><a
href="http://blog.dispatched.ch/wp-content/uploads/2009/05/vim-as-python-ide.png" rel="lightbox[777]"><img
class="size-full wp-image-799 aligncenter" title="vim-as-python-ide" src="http://blog.dispatched.ch/wp-content/uploads/2009/05/vim-as-python-ide.png" alt="VIM as Python IDE" width="491" height="401" /></a></p><p>So, these are my thoughts on a VIM setup for coding (Python).</p><p>Modern GUI VIM implementations like GVIM or MacVIM give the user the opportunity to organize their open files in tabs. This might look convenient, but to me it is rather bad practice, because a second tab will not be in the in the same buffer scope as the first one which takes away from future interaction options between the two. Using <a
title="MiniBuf" href="http://www.vim.org/scripts/script.php?script_id=159" target="_blank">MiniBufExplorer</a>, however, gives the user tabs(not only in the GUI, but also in command line) and leaves the classic buffer interaction intact.</p><p
style="text-align: center;"><a
href="http://blog.dispatched.ch/wp-content/uploads/2009/05/minibuf.png" rel="lightbox[777]"><img
class="size-full wp-image-784 aligncenter" title="minibuf" src="http://blog.dispatched.ch/wp-content/uploads/2009/05/minibuf.png" alt="MiniBuf Explorer" width="484" height="87" /></a></p><p>Being able to neatly work on multiple files, the user still misses the potential his favourite IDE gives him in visualizing classes, functions and variables. Luckily there are quite a few plugins around to accomplish this task just as well. My favourite one would be <a
title="TagList" href="http://vim-taglist.sourceforge.net/" target="_blank">TagList</a>. TagList uses <a
title="Exuberant CTags" href="http://ctags.sourceforge.net/" target="_blank">Exuberant Ctags</a> for actually generating the tags(note: it really relies on this specific version of ctags &#8211; preinstalled implementations on UNIX systems won&#8217;t work).</p><p
style="text-align: center;"><a
href="http://blog.dispatched.ch/wp-content/uploads/2009/05/taglist.png" rel="lightbox[777]"><img
class="size-full wp-image-787 aligncenter" title="taglist" src="http://blog.dispatched.ch/wp-content/uploads/2009/05/taglist.png" alt="TagList" width="481" height="260" /></a></p><p>A lot of coders have the habit of using TODO or FIXME statements in their code. Other IDEs often rely on having good third party project management software, but not VIM. There are great plugins like <a
title="TaskList" href="http://www.vim.org/scripts/script.php?script_id=2607" target="_blank">Tasklist</a> reminding the programmer of those lines of code. Tasklist even implements custom lists &#8211; to me that&#8217;s an incredible productivity gain.</p><p
style="text-align: center;"><a
href="http://blog.dispatched.ch/wp-content/uploads/2009/05/tasklist.png" rel="lightbox[777]"><img
class="size-full wp-image-781 aligncenter" title="tasklist" src="http://blog.dispatched.ch/wp-content/uploads/2009/05/tasklist.png" alt="TaskList" width="491" height="163" /></a></p><p>In these times, the programmer knows his or her programming language more or less by interactively finding out what it can do. Therefore code completion(sometimes also called IntelliSense*ugh*) is a major feature. I have heard  many people saying that this is where VIM fails &#8211; but luckily they are plain wrong(; In V7, VIM introduced <a
title="Omni Completion" href="http://vim.wikia.com/wiki/Omni_completion" target="_blank">omni completion</a> &#8211; given it is configured to recognize Python (if not, this feature is only a <a
title="Python Omni Completion" href="http://www.vim.org/scripts/script.php?script_id=1542" target="_blank">plugin</a> away) Ctrl+x Ctrl+o opens a drop down dialog like any other IDE &#8211; even the whole Pydoc gets to be displayed in a split window.</p><p
style="text-align: center;"><a
href="http://blog.dispatched.ch/wp-content/uploads/2009/05/omnicompletion.png" rel="lightbox[777]"><img
class="size-full wp-image-791 aligncenter" title="omnicompletion" src="http://blog.dispatched.ch/wp-content/uploads/2009/05/omnicompletion.png" alt="Omni Completion" width="436" height="312" /></a></p><p>Probably the most wanted feature(besides code completion) is debugging graphically. <a
title="VimPDB" href="http://code.google.com/p/vimpdb/" target="_blank">VimPDB</a> is a plugin that lets you do just that(. I acknowledge it is no complete substitution for a full fledged graphical debugger, but I honour the thought that having to rely on a debugger (often), is a hint of bad design.</p><p
style="text-align: center;"><a
href="http://blog.dispatched.ch/wp-content/uploads/2009/05/vimpdb.png" rel="lightbox[777]"><img
class="size-full wp-image-794 aligncenter" title="vimpdb" src="http://blog.dispatched.ch/wp-content/uploads/2009/05/vimpdb.png" alt="VimPDB" width="498" height="134" /></a></p><p>&#8211;</p><p
style="text-align: center;"><p
style="text-align: left;">From the eye-candy to the implementation. Don&#8217;t worry, it&#8217;s no sorcery.</p><p
style="text-align: left;">First of all, make sure you have VIM version 7.x installed, compiled with Python support. To check for the second, enter <em>:python print &#8220;hello, world&#8221;</em> into VIM. If you see an error message like <em>&#8220;E319: Sorry, the command is not available in this version&#8221;</em>, then it&#8217;s time to get a new one. If you&#8217;re on a Mac, just install MacVIM(there&#8217;s also a binary for the console in /Applications/MacVim.app/Contents/MacOS/). If you&#8217;re on Windows, GVIM will suffice(for versions != 2.4 search for the right <a
title="Vim for Windows32" href="http://www.gooli.org/blog/gvim-72-with-python-2526-support-windows-binaries/" target="_blank">plugin</a>). If you&#8217;re on any other machine, you will probably know how to compile your very own VIM with Python support.</p><p
style="text-align: left;">Second, check if you have a plugin directory. In Unix it would typically be located in <em>$HOME/.vim/plugin</em>, in Windows in the <em>Program Files </em>directory. If it doesn&#8217;t exist, create it.</p><p
style="text-align: left;">Now, let&#8217;s start with the MiniBufExplorer. <a
title="MiniBuf Explorer" href="http://www.vim.org/scripts/script.php?script_id=159" target="_blank">Get</a> it and copy it into your plugin directory. To start it automatically when needed and be able to use it with keyboard and mouse commands, append these lines in your vimrc configuration:</p><p><code>let g:miniBufExplMapWindowNavVim = 1<br
/> let g:miniBufExplMapWindowNavArrows = 1<br
/> let g:miniBufExplMapCTabSwitchBufs = 1<br
/> let g:miniBufExplModSelTarget = 1</code></p><p
style="text-align: left;">For a project view, get <a
title="TagList" href="http://vim-taglist.sourceforge.net/" target="_blank">TagList</a> and <a
title="Exuberant CTags" href="http://ctags.sourceforge.net/" target="_blank">Exuberant Ctags</a>. To install Ctags, unpack it, go into the directory and do a compile/install via:</p><p><code>./configure &amp;&amp; sudo make install</code></p><p>Ctags will then be installed in /usr/local/bin. When using a Windows machine, I recommend <a
href="http://cygwin.com/">Cygwin</a> with GCC and Make; it&#8217;ll work just fine. If you don&#8217;t want to tamper with your original ctags installation, you can propagate the location to VIM by appending the following line to vimrc:</p><p><code>let Tlist_Ctags_Cmd='/usr/local/bin/ctags'</code></p><p>To install TagList, just drop it into VIMs plugin directory. You will now be able to use the project view by typing the command <em>:TlistToggle</em>.</p><p><a
title="TaskList" href="http://www.vim.org/scripts/script.php?script_id=2607" target="_blank">Tasklist</a> is a simple plugin, too. Copying it into the plugin directory will suffice. I like to have shortcuts and have added<br
/> <code><br
/> map T :TaskList&lt;CR&gt;<br
/> map P :TlistToggle&lt;CR&gt;<br
/> </code></p><p>to vimrc. Pressing <em>T </em>will then open the TaskList if there are any tasks to process. <em>q </em>quits the TaskList again.</p><p><a
title="VimPDB" href="http://code.google.com/p/vimpdb/" target="_blank">VimPDB</a> is a plugin, as well. Install as before and see the readme for documentation. If it doesn&#8217;t work out of the box, watch for the known <a
title="Issuses VimPDB" href="http://code.google.com/p/vimpdb/issues/list" target="_blank">issues</a>.</p><p>To enable code(omni) completion, add this line to your vimrc:</p><p><code>autocmd FileType python set omnifunc=pythoncomplete#Complete</code></p><p>If it doesn&#8217;t work then, you&#8217;ll need this <a
title="Python Omni Completion" href="http://www.vim.org/scripts/script.php?script_id=1542" target="_blank">plugin</a>.</p><p
style="text-align: left;">My last two recommondations are setting these lines to comply to <a
title="PEP 8" href="http://www.python.org/dev/peps/pep-0008/" target="_blank">PEP 8</a>(Pythons&#8217; style guide) and to have decent eye candy:</p><p><code>set expandtab<br
/> set textwidth=79<br
/> set tabstop=8<br
/> set softtabstop=4<br
/> set shiftwidth=4<br
/> set autoindent<br
/> :syntax on</code></p><p>There are certainly a lot more flags to help productivity, but those will probably be more user specific.</p><p>Have fun coding Python while not being bound to a specific IDE, but having all the benefits of VIM bundled with a few helping hands. Enjoy, everyone.</p><p>If you liked this article, please feel free to re-tweet it and let others know.</p><table
border="0"><tbody><tr><td><script type="text/javascript">tweetmeme_url = 'http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/';</script><br
/> <script src="http://tweetmeme.com/i/scripts/button.js" type="text/javascript"></script></td><td>&nbsp;&nbsp;&nbsp;</td><td> You should follow me on twitter <a
href="http://twitter.com/preek">here</a><br
/> <a
href="http://twitter.com/preek"><img
class="alignnone" style="border: 0pt none;" title="twitter_preek" src="http://blog.dispatched.ch/wp-content/uploads/2009/05/twitter_preek.gif" border="0" alt="twitter_preek" width="180" height="18" /></a></td></tr></tbody></table> ]]></content:encoded> <wfw:commentRss>http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/feed/</wfw:commentRss> <slash:comments>99</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              44184
Template:           tag
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: blog.dispatched.ch @ 2012-02-10 15:07:42 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: basic
Cache key:          w3tc_blog.dispatched.ch_1_page_a9af0cff06b944c087f002b7358428ef_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.659s
Header info:
ETag:               "274915380f43058ea86f113a32d41d8b"
Last-Modified:      Mon, 16 Jan 2012 13:44:17 GMT
Vary:               Accept-Encoding, Cookie
X-Powered-By:       W3 Total Cache/0.9.2.4
Content-Encoding:   gzip
X-Pingback:         http://blog.dispatched.ch/xmlrpc.php
Content-Type:       text/xml; charset=UTF-8
-->
