vim-simple-todo
vim-simple-todo copied to clipboard
[feat] request: Create a new todo in current line if none, otherwise create below
Overwrite <leader>o since add [ ] to an already ToDo line is doubly the intention.
fun! SimpleTodoCheckAndCreateTodo()
let current_line = getline('.')
let is_task_line = current_line =~# '^\s*\(- \)\?\[ \?[x]\?\]'
if is_task_line
echo "current line is a task line, creating a new task below..."
execute "normal! \<Plug>(simple-todo-below)"
else
execute "normal! \<Plug>(simple-todo-new-start-of-line)"
endif
endf
nmap <silent> <leader>o :call SimpleTodoCheckAndCreateTodo()<CR>