I'm trying to create function and a mapping to insert/remove breakpoints in python code.
So far I got this
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()
execute 'args *.py'
silent! KeepView execute 'argdo g/\v^\s+(import pdb|pdb.set_trace)/de'
write
endfunction
I've tried both bufdo and argdo and none of them works properly. With bufdo it breaks with neovim terminal emulator buffers, saing buffer doesn't have some property. With argo do it shows some error very quickly and while it removes breakpoints it also messes my splits. For example it can change the active buffer in split to another.
Also argdo is really wouldn't work for me, because I don't need to search all python files, for large projects this would be too slow. I only need files that have been modified recently or more likely in that same editing session.
EDIT1
schedules = {
1: True,
import pdb;pdb.set_trace()
2: True,
3: True,
4: True,
5: True,
6: False,
7: False,
}
There's a test file for you.
in the same editing session
. Are these files still open in another tab or buffer?pdb
have a command that does just that? I.e. without the need to specify any file. Something likepdb.clear
, say (if such command exists).autocmd BufWritePost * add(g:edditedFiles, expand('%:p')
and then use a for loop over that list whenever I wanted to do the "global" edit.