Skip to main content

Vim and Pdb integration

Project description

Abstract

This package provides an integration of the Python debugger pdb into the VIM editor.

Requirements

vimpdb requires a VIM that supports both python and clientserver options.

Find out if it is the case by issuing the following command at the VIM prompt:

:version

If the options are supported, you will see +clientserver and +python in the output. In the opposite case, you will see -clientserver or -python.

For Mac OS X, you’ll want to use MacVIM, for Linux and Windows the default build should be already server-enabled. MacVIM has python compiled in by default, also.

Installation

Just install this package using easy_install or similar:

$ easy_install vimpdb

Configuration

You might need to setup the VIMPDB_VIMSCRIPT environment variable. It should hold the command used at the shell prompt to launch a VIM supporting the options mentioned above. (Default value is vimpdb).

This script should also set the --servername option to specify a server name. You can think of this as a “window name” which is used to send remote commands to – this is how vimpdb communicates with a certain VIM instance.

Server Name

You might need to setup the VIMPDB_SERVERNAME environment variable. It should hold the name of the VIM server you will be using. (Default value is VIMPDB). You may list the currently running VIM servers using:

$ vim --serverlist
VIM

Or, on a Mac:

$ /Applications/MacVim.app/Contents/MacOS/Vim --serverlist
VIM

Note that the default servername is VIM

Starting a VIM Server for Debugging

You may start a VIM server for debugging like so:

$ vim --servername VIMPDB

Or, on a Mac, if you installed the mvim script:

$ mvim --servername VIMPDB

When a VIM supporting clientserver option has started, you can find its name by issuing the following command at the VIM prompt:

:echo v:servername

Using

Using vimpdb is easy – just call set_trace as usual:

import vimpdb; vimpdb.set_trace()

Now, when the python interpreter hits that line, VIM will get the focus and load the source file.

Now you’ll be able to use the following commands:

VimPDB Commands

Key

Command

n

Next

s

Step

a

Args

u

Up

d

Down

r

Return

c

Continue

b

Sets a breakpoint at the line on which the cursor is sitting.

w

Displays the value of the word on which the cursor is sitting.

x

Switch to debugging with standard Pdb.

v

Switch back to VimPdb from plain Pdb.

Standard Pdb hook

If you find it hard to change habits and keep on typing

import pdb; pdb.set_trace()

you can add the following line to the .pdbrc file sitting in your home folder:

import vimpdb; vimpdb.hookPdb()

This way, the command v(im) mentioned above is added to your standard Pdb and you can switch to vimpdb at any time.

Known issues

  • Currently, when you stop debugging, the buffers which you debugged with are left in an inconvenient state : the keys mapped to Pdb commands are still mapped. In other words, switching from debugging to fixing code is not convenient.

CREDITS

Changelog

0.3.2 (2010-03-03)

  • more documentation

0.3.1 (2010-03-02)

  • fix setup.py metadata so that it does not hold non ascii chars. This avoided actual release to PyPI

0.3 (2010-03-02)

  • fully rewritten

0.2.1 (2008-06-27)

  • added vimpdb script

  • added “exit” callback

0.2 (2008-06-17)

  • first release to PyPi

TODO

  • add option to allow other network settings (instead of hardcoded)

  • try to start Vim server if it is not started

  • try to guess Vim server name to avoid use of VIMPDB_SERVERNAME

  • check and complain if Vim does not support the right options

  • add command to set/reset key mappings/readonly state to allow to switch to editing mode

  • register menu

  • and much more…

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vimpdb-0.3.2.tar.gz (7.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page