From 639fcd85a23f2ec600a1ea52e2fe524eb0d65f71 Mon Sep 17 00:00:00 2001 From: Leandro Freitas Date: Thu, 16 Apr 2015 20:25:58 -0300 Subject: [PATCH] Implemented sorting on visual selection. --- ftplugin/todo.vim | 26 +++++++++++++++++++++++--- test/tc_sort_context.todo.txt | 2 ++ test/tc_sort_context.vim | 4 +--- test/tc_sort_project.todo.txt | 2 ++ test/tc_sort_project.vim | 4 +--- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index b274095..099e5a2 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -81,18 +81,38 @@ function! TodoTxtRemoveCompleted() call s:AppendToFile(l:done_file, l:completed) endfunction +function! TodoTxtSortByContext() range + execute a:firstline . "," . a:lastline . "sort /\\(^\\| \\)\\zs@[^[:blank:]]\\+/ r" +endfunction + +function! TodoTxtSortByProject() range + execute a:firstline . "," . a:lastline . "sort /\\(^\\| \\)\\zs+[^[:blank:]]\\+/ r" +endfunction + " Mappings {{{1 " Sort tasks {{{2 if !hasmapto("s",'n') - nnoremap