I'm mostly developing with python. I'm using pdbpp as python debugger so I'm contantly adding
import pdb;pdb.set_trace()
or
import pdb
pdb.set_trace()
So I wrote couple of functions.
function! AddBreakPoint()
let l:line = line('.')
let l:indentChar = ' '
call append(l:line - 1, repeat(l:indentChar, indent(l:line)) . "import pdb;pdb.set_trace")
endfunction
function! RemoveAllBreakPoints()
write
silent! execute 'bufdo g/\v^\s+(import pdb|pdb.set_trace)/de'
endfunction
The problem with that now is that RemoveAllBreakPoints()
messes relative position of cursor on the screen. So for example if the cursor was in the middle of the screen after zz
it would be on the same line, but this line suddenly appears at the bottom of the screen.
EDIT1 OK, I solved it with KeepView plugin, but could someone explain to me why vim doing that and is there a native way to keep view after executing command?