This would be much simpler to do with a real snippet, rather than a command. Choose "New Snippet" from the bottom-left of the bundle editor, and then just type "import pdb; pdb.set_trace()" in the big box. This can be tab- or shortcut-activated.
<br><br>Also, I don't really know python, but I'm guessing that you only need to import pdb once per file; afterwards, you can just use pdb.set_trace().<br><br><div><span class="gmail_quote">On 4/13/07, <b class="gmail_sendername">
Yi Qiang</b> <<a href="mailto:yqiang@gmail.com">yqiang@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,
<br>I am a relatively new TextMate user and am still learning all the ins<br>and outs of it, but it certainly is a lot of fun :)  When I am doing<br>python development, a lot of times I just want to set a breakpoint in<br>
my code, and the way to do that in python is:<br><br>import pdb; pdb.set_trace()<br><br>Typing that each time got boring, so I wrote this little snippet for<br>it.  I would like some feedback, especially with the way I am
<br>figuring out the right indentation level :)<br><br>------------------------------------------------------------------------<br>#!/usr/bin/env python<br># This TextMate command inserts a breakpoint ABOVE the currently<br>
selected line<br># Yi Qiang (yqiang _at_ gmail dot com)<br><br>import os<br>import sys<br><br>text = sys.stdin.readlines()<br>line_number = int(os.getenv('TM_LINE_NUMBER')) - 1 # TM counts from 1<br>spaces = (len(text[line_number]) - len(text[line_number].expandtabs
<br>(4).lstrip()))<br>debug_string = (' ' * (spaces)) + 'import pdb; pdb.set_trace()\n'<br>text.insert(line_number, debug_string)<br>sys.stdout.write(''.join(text))<br><br>------------------------------------------------------------------------
<br>-<br><br>Cheers,<br>Yi<br><br>--<br><a href="http://www.yiqiang.net">http://www.yiqiang.net</a><br><br><br><br>______________________________________________________________________<br>For new threads USE THIS: <a href="mailto:textmate@lists.macromates.com">
textmate@lists.macromates.com</a><br>(threading gets destroyed and the universe will collapse if you don't)<br><a href="http://lists.macromates.com/mailman/listinfo/textmate">http://lists.macromates.com/mailman/listinfo/textmate
</a><br></blockquote></div><br>