Created
August 13, 2010 19:30
-
-
Save berinhard/523420 to your computer and use it in GitHub Desktop.
A script to enable easy ipdb usage for Vim users.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Author: Bernardo Fontes <[email protected]> | |
" Website: http://www.bernardofontes.net | |
" This code is based on this one: http://www.cmdln.org/wp-content/uploads/2008/10/python_ipdb.vim | |
" I worked with refactoring and it simplifies a lot the remove breakpoint feature. | |
" To use this feature, you just need to copy and paste the content of this file at your .vimrc file! Enjoy! | |
python << EOF | |
import vim | |
import re | |
ipdb_breakpoint = 'import ipdb; ipdb.set_trace()' | |
def set_breakpoint(): | |
breakpoint_line = int(vim.eval('line(".")')) - 1 | |
current_line = vim.current.line | |
white_spaces = re.search('^(\s*)', current_line).group(1) | |
vim.current.buffer.append(white_spaces + ipdb_breakpoint, breakpoint_line) | |
vim.command('map <C-I> :py set_breakpoint()<cr>') | |
def remove_breakpoints(): | |
op = 'g/^.*%s.*/d' % ipdb_breakpoint | |
vim.command(op) | |
vim.command('map <C-P> :py remove_breakpoints()<cr>') | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a simpler VimL version: