Fast Python debugging with Vim

So I just needed to test some lines of Gtk+ code and preferably with Python. I love the interpreter (just as well as irb) but debugging even small Gtk+ pieces is not very attractive in the end. Therefore I jumped into Vim, typed my small script, and then executed the command ":%!python -". Only problem is that after the command exits it replaces the content of the Vim buffer with the console output that contains Python debugging messages as well, a quick press on "u" reverts this but maybe there is a cleaner way.


  1. Hi Mike,

    something which might be more useful and doesn't have the buffer problem :

    add to your vimrc :

    au FileType python set makeprg=python
    map! <C-B> <Esc>:w<Esc>:make %<Esc>
    map <C-B> <Esc>:w<Esc>:make %<Esc>

    after that, while editing your file, press ctrl-b, this will run the python interpreter on your current file. This works for ruby files as well ;)