" lib.vim - Miscelaneous functions " " Author: Silvio Rhatto " " Checkbox handling " " Thanks https://www.reddit.com/r/vim/comments/slqsao/readymade_solution_for_handling_markdown/ "function! ToggleCheckbox() " let line = getline('.') " " if line =~ '- \[ \]' " call setline('.', substitute(line, '- \[ \]', '- \[x\]', '')) " elseif line =~ '- \[x\]' " call setline('.', substitute(line, '- \[x\]', '- \[ \]', '')) " elseif line =~ '- ' " call setline('.', substitute(line, '- ', '- \[ \] ', '')) " endif "endf " "nnoremap c :call ToggleCheckbox()