Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " Simple todo function
- nnoremap <leader>to :ToggleCompletion<cr>ddGpggj
- 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 <sid>ToggleCompletion()
- nnoremap X :ToggleCompletion<cr>
- syntax match doneTodo "\v%(\s+)?- \[x\].*"
- highlight link doneTodo Comment
- function! s:Todo()
- 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("\<Plug>Todo", 0)
- endfunction
- command! Todo call <sid>Todo()
- nnoremap <Plug>Todo :Todo<cr>
- map <leader>nt <Plug>Todo
- " vim:ft=vim
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement