Skip to content

Commit

Permalink
Add action and mapping to unmark as done + fix freitass#64
Browse files Browse the repository at this point in the history
  • Loading branch information
isti115 committed May 15, 2021
1 parent ed9d639 commit f840e25
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ Date:
`<localleader>d` Set current task's creation date to the current date
`date<tab>` (Insert mode) Insert the current date

Mark as done:
Mark / unmark as done:
`<localleader>x` Mark current task as done
`<localleader>X` Mark all tasks as done
`<localleader>u` Mark current task as undone
`<localleader>U` Mark all tasks as undone
`<localleader>D` Move completed tasks to done.txt

This plugin detects any text file with the name todo.txt or done.txt with an optional prefix that ends in a period (e.g. second.todo.txt, example.done.txt).
Expand Down
10 changes: 9 additions & 1 deletion autoload/todo/txt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function! todo#txt#replace_date()
endfunction

function! todo#txt#mark_as_done()
call s:remove_priority()
" call s:remove_priority()
call todo#txt#prepend_date()
execute 'normal! Ix '
endfunction
Expand All @@ -48,6 +48,14 @@ function! todo#txt#mark_all_as_done()
:g!/^x /:call todo#txt#mark_as_done()
endfunction

function! todo#txt#unmark_as_done()
:s/^x \(\d\{2,4\}-\d\{2\}-\d\{2\} \)\?//ge
endfunction

function! todo#txt#unmark_all_as_done()
:g/^x /:call todo#txt#unmark_as_done()
endfunction

function! s:append_to_file(file, lines)
let l:lines = []

Expand Down
7 changes: 7 additions & 0 deletions ftplugin/todo.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ vnoremap <script> <silent> <buffer> <localleader>x :call todo#txt#mark_as_done()
" Mark all done {{{2
nnoremap <script> <silent> <buffer> <localleader>X :call todo#txt#mark_all_as_done()<CR>
" Unmark done {{{2
nnoremap <script> <silent> <buffer> <localleader>u :call todo#txt#unmark_as_done()<CR>
vnoremap <script> <silent> <buffer> <localleader>u :call todo#txt#unmark_as_done()<CR>
" Unmark all done {{{2
nnoremap <script> <silent> <buffer> <localleader>U :call todo#txt#unmark_all_as_done()<CR>
" Remove completed {{{2
nnoremap <script> <silent> <buffer> <localleader>D :call todo#txt#remove_completed()<CR>
Expand Down

0 comments on commit f840e25

Please sign in to comment.