Shared State

Jeff McGee's Blog of Messages Worth Passing

Create a Python Breakpoint in Vim

Posted on Thu 18 August 2011 in Tips

Pdb is Python's built-in debugger. To make it easier to start pdb, I added this line to my .vimrc:

noremap <D-d> Oimport pdb; pdb.set_trace()<Esc>:w<Return>

When I type Command-d in normal mode, vim will insert the line import pdb; pdb.set_trace() and save the current file. When I run the python program, and that line is excuted, the Python program will pause and start pdb.

my photo

Jeff McGee — builder, problem solver, teacher, and general nerd.

jeffamcgee AT gmail