Fork this blog on GitHub Fork this blog on GitHub

Customizing Vim to Easily Add Python Breakpoints

I added a few lines to my .vimrc today in my ongoing effort to be more productive and type fewer key strokes.

First I changed the <leader> variable from a backslash to a comma which is easier to type.  The leader variable is useful for creating custom commands.

"Easier mapleader than the default "\"
let mapleader = ","

Instead of manually typing "import ipdb; ipdb.set_trace()", the following vim configuration will insert a python breakpoint in the next line by typing ,p in normal mode.  As the comment explains, ctrl v and then escape must be typed in order to create the characters at the end.

" type ,p to insert breakpoint. ^[ is at the end.  Insert with ctrl v and then esc
" (the github web gui doesn't display control characters, but it is there)
nnoremap <leader>p oimport ipdb;ipdb.set_trace()^[

This next bit is useful for removing a breakpoint and preserving the newline.  I mapped this to W key

" type ,W to wipe the whole line clean but keep the \n
nnoremap <leader>W 0d$

My whole .vimrc file may be found on Github:

Please let me know if this is helpful or if you have any suggestions!


Next entry

Previous entry

Similar entries


  1. isabel marant sneaker

    isabel marant sneaker on 11/20/2012 2:42 a.m.

    It's just what I was searching for. I am always interested in this subject. Thanks for sharing.

  2. thens

    thens on 02/06/2013 2:06 p.m.

    Don't know if you still following this blog/post, but is always an interesting resource for this kind of stuff :)

Post your comment


Pingbacks are closed.