" Todo file functionality "------------------------ " Simple todo function nnoremap dn :ToggleCompletionddGpggj function! s:ToggleCompletion() let save_cursor = getpos(".") if match(getline('.'), '- \[\s\]') != -1 substitute/\[\s\]/[x]/ else substitute/\[x\]/[ ]/ endif call setpos('.', save_cursor) endfunction command! ToggleCompletion call ToggleCompletion() nnoremap X :ToggleCompletion syntax match doneTodo "\v%(\s+)?- \[x\].*" highlight link doneTodo Comment function! s:MakeTodo() let save_cursor = getpos(".") let has_dash = (match(getline('.'), '\v^\s?- \w') != -1) if has_dash s/\v(\s+)?- (.*)/\1- [ ] \2/ call setpos('.', save_cursor) normal! 4l else s/\v(\s+)?(.*)/\1- [ ] \2/ call setpos('.', save_cursor) normal! 6l endif silent! call repeat#set("\MakeTodo", 0) endfunction command! MakeTodo call MakeTodo() nnoremap MakeTodo :MakeTodo map ut MakeTodo " vim:ft=vim