diff --git a/README.markdown b/README.markdown index 27e5d9f..9b2ec1f 100644 --- a/README.markdown +++ b/README.markdown @@ -259,3 +259,7 @@ Possible values are : + `X` : Mark all tasks as completed + `D` : Move completed tasks to done file, see [TodoTxt Files](#todotxt-files) + +### Format + ++ `ff` : Try to fix todo.txt format diff --git a/autoload/todo.vim b/autoload/todo.vim index 38d763a..5f72dc8 100644 --- a/autoload/todo.vim +++ b/autoload/todo.vim @@ -77,6 +77,13 @@ function! todo#ToggleMarkAsDone(status) endif endfunction +function! todo#FixFormat() + " Remove heading space + silent! %s/\C^\s*// + " Remove priority from done tasks + silent! %s/\C^x (\([A-Z]\)) \(.*\)/x \2 pri:\1/ +endfunction + function! todo#UnMarkAsDone(status) if a:status=='' let pat='' @@ -84,12 +91,14 @@ function! todo#UnMarkAsDone(status) let pat=' '.a:status endif exec ':s/\C^x\s*\d\{4}-\d\{1,2}-\d\{1,2}'.pat.'\s*//g' + silent s/\C\(.*\) pri:\([A-Z]\)/(\2) \1/ endfunction function! todo#MarkAsDone(status) if a:status!='' exec 'normal! I'.a:status.' ' endif + exec ':s/\C^(\([A-Z]\))\(.*\)/\2 pri:\1' call todo#PrependDate() if (getline(".") =~ '^ ') normal! gIx diff --git a/doc/todo.txt b/doc/todo.txt index 7854fa8..087c25f 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -27,6 +27,7 @@ Table of Contents *TodoTxt-Contents* ~ 6.2 Priorities...............................|TodoTxt-Priorities| 6.3 Dates....................................|TodoTxt-Dates| 6.4 Done.txt.................................|TodoTxt-Done| + 6.5 Format...................................|TodoTxt-Format| =============================================================================== 1. Release notes *TodoTxt-ReleaseNotes* ~ @@ -284,3 +285,7 @@ Possible values are : `D` : Move completed tasks to done file, see |TodoTxt-Files| `` is \ by default, so ̀`-s` means you type \s + +6.5 Format *TodoTxt-format* + + `ff` : Try to fix todo.txt format diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index 0f803b4..c270b47 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -71,6 +71,8 @@ if !exists("g:Todo_txt_do_not_map") " Sort by due: date {{{2 nnoremap