From 303ab65237e1abb6d42bec02f9deee5e52be0276 Mon Sep 17 00:00:00 2001 From: David Karwowski Date: Wed, 28 Sep 2016 12:31:37 -0400 Subject: [PATCH] priorities at top, x at bottom --- autoload/todo.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/autoload/todo.vim b/autoload/todo.vim index dcc3103..819cce2 100644 --- a/autoload/todo.vim +++ b/autoload/todo.vim @@ -140,6 +140,21 @@ function! todo#Sort() sort /@[a-zA-Z]*/ r sort /+[a-zA-Z]*/ r sort /\v\([A-Z]\)/ r + " Count the number of lines + silent normal gg + execute "/^\([A-Z]\)/" + 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/\(x\s*\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g + sort n /^x\s*/ + silent! %s/\(x\s*\d\{4}\)\(\d\{2}\)/\1-\2-/g endif endfunction