Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start date sorting #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Sorting tasks:
`<localleader>s@` Sort the file on @Contexts
`<localleader>sd` Sort the file on dates
`<localleader>sdd` Sort the file on due dates
`<localleader>sdt` Sort the file on start dates as represented by the "t" metadata key (e.g., "t:2017-11-23")

Edit priority:
`<localleader>j` Decrease the priority of the current line
Expand Down
6 changes: 6 additions & 0 deletions autoload/todo/txt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ function! todo#txt#sort_by_due_date() range
execute a:firstline . "," . a:lastline . "g!/" . l:date_regex . "/m" . a:lastline
endfunction

function! todo#txt#sort_by_start_date() range
let l:date_regex = "t:\\d\\{2,4\\}-\\d\\{2\\}-\\d\\{2\\}"
execute a:firstline . "," . a:lastline . "sort /" . l:date_regex . "/ r"
execute a:firstline . "," . a:lastline . "g!/" . l:date_regex . "/m" . a:lastline
endfunction

" Increment and Decrement The Priority
:set nf=octal,hex,alpha

Expand Down
1 change: 1 addition & 0 deletions doc/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CONTENTS *todo-contents*
`<localleader>s@` Sort the file on @Contexts
`<localleader>sd` Sort the file on dates
`<localleader>sdd` Sort the file on due dates (i.e. due:2015-10-25)
<localleader>sdt Sort the file on due dates (i.e. t:2015-10-25)

1.2 Edit priority: *todo-commands-priority*
`<localleader>j` Decrease the priority of the current line
Expand Down
2 changes: 2 additions & 0 deletions ftplugin/todo.vim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ nnoremap <script> <silent> <buffer> <localleader>sd :%call todo#txt#sort_by_date
vnoremap <script> <silent> <buffer> <localleader>sd :call todo#txt#sort_by_date()<CR>
nnoremap <script> <silent> <buffer> <localleader>sdd :%call todo#txt#sort_by_due_date()<CR>
vnoremap <script> <silent> <buffer> <localleader>sdd :call todo#txt#sort_by_due_date()<CR>
nnoremap <script> <silent> <buffer> <localleader>sdt :%call todo#txt#sort_by_start_date()<CR>
vnoremap <script> <silent> <buffer> <localleader>sdt :call todo#txt#sort_by_start_date()<CR>

" Change priority {{{2
nnoremap <script> <silent> <buffer> <localleader>j :call todo#txt#prioritize_increase()<CR>
Expand Down