mirror of
https://github.com/freitass/todo.txt-vim.git
synced 2025-11-15 21:33:46 -05:00
Implemented sorting on visual selection.
This commit is contained in:
@@ -81,18 +81,38 @@ function! TodoTxtRemoveCompleted()
|
||||
:g/^x /call add(l:completed, getline(line(".")))|d
|
||||
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("<leader>s",'n')
|
||||
if !hasmapto("<leader>s",'n')
|
||||
nnoremap <script> <silent> <buffer> <leader>s :%sort<CR>
|
||||
endif
|
||||
|
||||
if !hasmapto("<leader>s",'v')
|
||||
vnoremap <script> <silent> <buffer> <leader>s :sort<CR>
|
||||
endif
|
||||
|
||||
if !hasmapto("<leader>s@",'n')
|
||||
if !hasmapto("<leader>s@",'n')
|
||||
nnoremap <script> <silent> <buffer> <leader>s@ :%call TodoTxtSortByContext()<CR>
|
||||
endif
|
||||
|
||||
if !hasmapto("<leader>s@",'v')
|
||||
vnoremap <script> <silent> <buffer> <leader>s@ :call TodoTxtSortByContext()<CR>
|
||||
endif
|
||||
|
||||
if !hasmapto("<leader>s+",'n')
|
||||
if !hasmapto("<leader>s+",'n')
|
||||
nnoremap <script> <silent> <buffer> <leader>s+ :%call TodoTxtSortByProject()<CR>
|
||||
endif
|
||||
|
||||
if !hasmapto("<leader>s+",'v')
|
||||
vnoremap <script> <silent> <buffer> <leader>s+ :call TodoTxtSortByProject()<CR>
|
||||
endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user