better due date sorting and due compeltion
This commit is contained in:
@@ -32,7 +32,7 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
|
||||
|
||||
`<LocalLeader>s@` : Sort the file on @Contexts
|
||||
|
||||
`<leader>-sd` : Sort @_sched entries by due-date
|
||||
`<leader>-sd` : Sort the file by due-date
|
||||
|
||||
`<LocalLeader>j` : Lower the priority of the current line
|
||||
|
||||
@@ -48,6 +48,8 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
|
||||
|
||||
`date<tab>` : (Insert mode) Insert the current date
|
||||
|
||||
`due:` : (Insert mode) Insert 'due:' followed by the current date
|
||||
|
||||
`<LocalLeader>x` : Toggle mark task as done (inserts current date as completion date)
|
||||
|
||||
`<LocalLeader>X` : Mark all tasks as completed
|
||||
|
||||
@@ -79,15 +79,28 @@ endfunction
|
||||
|
||||
function! TodoTxtSort()
|
||||
" vim :sort is usually stable
|
||||
" we sort first on contexts, then on projects and then on priority
|
||||
:sort /@[a-zA-Z]*/ r
|
||||
:sort /+[a-zA-Z]*/ r
|
||||
" we sort first on contexts, then on projects and then on priority
|
||||
sort /@[a-zA-Z]*/ r
|
||||
ssort /+[a-zA-Z]*/ r
|
||||
sort /\v\([A-Z]\)/ r
|
||||
endfunction
|
||||
|
||||
function! TodoTxtSortDue()
|
||||
:silent! %s/\(due:\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
|
||||
:sort! n /due:/
|
||||
function! TodoTxtSortDue()
|
||||
silent! %s/\(due:\s*\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
|
||||
" Sort adding entries with due dates add the beginning
|
||||
sort n /due:/
|
||||
" Count the number of lines
|
||||
silent normal gg
|
||||
execute "/due:"
|
||||
let l:first=getpos(".")[1]
|
||||
silent normal N
|
||||
let l:last=getpos(".")[1]
|
||||
let l:diff=l:last-l:first+1
|
||||
" Put the sorted lines at the beginning of the file
|
||||
execute ':'.l:first
|
||||
execute ':d'.l:diff
|
||||
silent normal gg
|
||||
silent normal P
|
||||
silent! %s/\(due:\s*\d\{4}\)\(\d\{2}\)/\1-\2-/g
|
||||
" TODO: add time sorting (YYYY-MM-DD HH:MM)
|
||||
endfunction
|
||||
@@ -188,6 +201,10 @@ if !hasmapto("date<Tab>",'i')
|
||||
if !hasmapto("date<Tab>",'i')
|
||||
inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR>
|
||||
endif
|
||||
|
||||
if !hasmapto("due:",'i')
|
||||
inoremap <script> <silent> <buffer> due: due: <C-R>=strftime("%Y-%m-%d")<CR>
|
||||
endif
|
||||
|
||||
if !hasmapto("<localleader>d",'n')
|
||||
nnoremap <script> <silent> <buffer> <localleader>d :call TodoTxtPrependDate()<CR>
|
||||
@@ -215,7 +232,7 @@ if !hasmapto("<localleader>D",'n')
|
||||
if !hasmapto("<localleader>D",'n')
|
||||
nnoremap <script> <silent> <buffer> <localleader>D :call TodoTxtRemoveCompleted()<CR>
|
||||
endif
|
||||
|
||||
|
||||
" Sort by due: date {{{2
|
||||
if !hasmapto("<localleader>sd".'n')
|
||||
nnoremap <script> <silent> <buffer> <localleader>sd :call TodoTxtSortDue()<CR>
|
||||
|
||||
Reference in New Issue
Block a user