On any line in a markdown file that starts with AR, <Shift-Enter> will add this line to the todo list, with the current date and the name of the originating file.

Alternatively, :AR will do the same thing, regardless of how the line starts.

In the todo file all open action start in o (lower case o). <Ctrl-a> toggles o to (check mark) and moves the line to under the # Done heading, with the completion date appended.


In a markdown file

 AR Write a todo list

gets added to the file as:

   # TODOs
  o Write a todo list  (2 Jan 24)  in: o Do some actual work  (1 Jan 20)  in:  # DONE
  1 Jan 2024 ✓ Think about a todo list  (12 Aug 21)  in:  

When the action is complete, <Ctrl-a> toggles the o to and moves the line to the # Done section:

   # TODOs
  o Do some actual work  (1 Jan 20)  in:  # DONE
  05 Jan 2024 ✓ Write a todo list  (2 Jan 24)  in:  1 Jan 2024 ✓ Think about a todo list  (12 Aug 21)  in:   


Add the following to your .vimrc or other files that get sourced when starting vim.

 command! AR call TakeAction()
  fu! TakeAction()
   let line = substitute(getline('.'), '^AR ', '', '')
   let action = 'o '.line.' '.strftime("  (%d %b %y)").'\t in: '.expand('%:r')
   execute "!sed -i '' '3s/^/".action."\\n/' $PATH/TO/YOUR/"
   echomsg 'Action: "'.getline('.').'" taken'

For the <Ctrl-a> mapping, add:

 nnoremap <C-a> :call Toggle('+')<CR>
  function! Toggle(change)
   let cStr = matchstr(getline('.'), '\%' . col('.') . 'c.')
   if (cStr == "o")
     " move item to 'done' list
     normal ciw✓
     normal ddmo
     /^# DONE\n/
     normal j
     r! date "+\%d \%b \%Y"
     normal p`o

cStr is the character under the cursor. If it is o, it is replaced with and the line is moved to the # Done section of the todo file. I use the <C-a> and <C-x> mappings for many other toggles, such as number increments or switching between True and False.

For the <Shift-Enter> mapping, add something like:

 function! Process()
   if getline('.') =~ '^AR '
     call TakeAction()
   endif   […] endfunction  nnoremap <buffer><S-ENTER>  :call Process()<CR>

!sed… inserts the action as the third line into the todo file (to leave space for a title)

Again, I use <S-Enter> for many other things besides. Lines starting with > get executed as shell commands. Otherwise it 'executes' the file depending on type (python is run, emails are sent, markdown turned into pdf or website…)