Last Updated: February 25, 2016
·
582
· hoffoo

Vim copy breakpoint for gdb

I love gdb, but setting breakpoints can be a hassle without a large plugin. I use this in vim to copy to my clipboard:

" vim beakpoint format to clipboard
func! CopyAsBreakpoint()
    let s:pos=expand('%:p') . ':' . line('.')
    call system("xclip", s:pos)
 endfunc
 " map to a key
 map <F5> :call CopyAsBreakpoint()<cr>

It will put something like this in your clipboard: /tmp/teh.go:7

As far as I know xclip is Linux only, other platforms will need something that sends stdin to your clipboard.