Skip to content

[feat] request: Create a new todo in current line if none, otherwise create below #41

@juanMarinero

Description

@juanMarinero

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions