Quantcast
Channel: Charles O'Brien - Entries for the tag howto
Viewing all articles
Browse latest Browse all 5

Customizing Vim to Easily Add Python Breakpoints

$
0
0

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: https://github.com/pycharles/dotfiles

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

 


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images