diff --git a/README.markdown b/README.markdown index 7726b71..fce3085 100644 --- a/README.markdown +++ b/README.markdown @@ -20,11 +20,24 @@ a nice two level sorting function designed for todo.txt files (see section ## Features included in Freitass version -This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few -mappings, to help with edition of these files: +This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few mappings, to help with editing these files: `-s` : Sort the file +`-s+` : Sort the file on +Projects + +`-s@` : Sort the file on @Contexts + +`-j` : Lower the priority of the current line + +`-k` : Increase the priority of the current line + +`-a` : Add the priority (A) to the current line + +`-b` : Add the priority (B) to the current line + +`-c` : Add the priority (C) to the current line + `-d` : Insert the current date `date` : (Insert mode) Insert the current date @@ -33,9 +46,9 @@ mappings, to help with edition of these files: `-X` : Mark all tasks as completed -`-D` : Remove completed tasks +`-D` : Move completed tasks to done.txt -If you want the help installed run ":helptags ~/.vim/doc" inside vim after having copied the files. +If you want the help installed, run ":helptags ~/.vim/doc" inside vim after having copied the files. Then you will be able to get the commands help with: :h todo.txt ## New features diff --git a/Todo.txt b/Todo.txt deleted file mode 100644 index ad5e0cb..0000000 --- a/Todo.txt +++ /dev/null @@ -1,13 +0,0 @@ -(A) 2011-05-30 Map commands to add, rm, ls, pri, depri etc @ftplugin -(A) 2011-06-06 Check file syntax @syntax -(B) 2011-05-31 Start documentation @doc -(C) 2011-06-01 Improve syntax file @syntax -x 2014-04-27 2011-05-30 Contact main project for reference -x 2011-05-30 Create README.markdown to be published in github @doc -x 2011-05-30 Implement colorized priorities @syntax -x 2011-05-30 Implement filetype detection @ftdetect -x 2011-05-30 Sort lines per priority @ftplugin -x 2011-05-31 Highlight date, project and context of tasks with no priority @syntax -x 2011-05-31 Stop breaking lines automatically @ftplugin -x 2011-06-06 Easier date input @ftplugin -x 2011-06-06 Implement foldings @ftplugin diff --git a/doc/todo.txt b/doc/todo.txt index 63d4a2b..e9e07ac 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -5,6 +5,10 @@ COMMANDS *todo-commands* `-s` : Sort the file by priority +`-s+` : Sort the file on +Projects + +`-s@` : Sort the file on @Contexts + `-sc` : Sort the file by context then by priority `-scp` : Sort the file by context, project then by priority @@ -13,6 +17,16 @@ COMMANDS *todo-commands* `-spc` : Sort the file by project, context then by priority +`-j` : Lower the priority of the current line + +`-k` : Increase the priority of the current line + +`-a` : Add the priority (A) to the current line + +`-b` : Add the priority (B) to the current line + +`-c` : Add the priority (C) to the current line + `-d` : Insert the current date `date` : (Insert mode) Insert the current date @@ -22,7 +36,7 @@ COMMANDS *todo-commands* `-X` : Mark all tasks as completed -`-D` : Remove completed tasks +`-D` : Move completed tasks to done.txt is \ by default, so -s means you type \s @@ -40,4 +54,5 @@ Defaults values are: g:Todo_txt_first_level_sort_mode="i" g:Todo_txt_second_level_sort_mode="i" + For more information on the available flags see help :sort diff --git a/ftdetect/todo.vim b/ftdetect/todo.vim index d16a6ee..a12a122 100644 --- a/ftdetect/todo.vim +++ b/ftdetect/todo.vim @@ -1,9 +1,10 @@ " File: todo.txt.vim " Description: Todo.txt filetype detection " Author: Leandro Freitas -" Licence: Vim licence -" Website: http://github.com/freitass/todo.txt.vim +" License: Vim license +" Website: http://github.com/freitass/todo.txt-vim " Version: 0.1 autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo +autocmd BufNewFile,BufRead [Dd]one.txt set filetype=todo diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index b394885..e4ad1e8 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -1,8 +1,8 @@ " File: todo.txt.vim " Description: Todo.txt filetype detection " Author: Leandro Freitas -" Licence: Vim licence -" Website: http://github.com/freitass/todo.txt.vim +" License: Vim license +" Website: http://github.com/freitass/todo.txt-vim " Version: 0.4 " Save context {{{1 @@ -16,7 +16,7 @@ set cpo&vim setlocal textwidth=0 setlocal wrapmargin=0 -" Functions {{{! +" Functions {{{1 function! s:TodoTxtRemovePriority() :s/^(\w)\s\+//ge endfunction @@ -47,8 +47,33 @@ function! TodoTxtMarkAllAsDone() :g!/^x /:call TodoTxtMarkAsDone() endfunction +function! s:AppendToFile(file, lines) + let l:lines = [] + + " Place existing tasks in done.txt at the beggining of the list. + if filereadable(a:file) + call extend(l:lines, readfile(a:file)) + endif + + " Append new completed tasks to the list. + call extend(l:lines, a:lines) + + " Write to file. + call writefile(l:lines, a:file) +endfunction + function! TodoTxtRemoveCompleted() - :g/^x /d + " Check if we can write to done.txt before proceeding. + let l:target_dir = expand('%:p:h') + let l:done_file = l:target_dir.'/done.txt' + if !filewritable(l:done_file) && !filewritable(l:target_dir) + echoerr "Can't write to file 'done.txt'" + return + endif + + let l:completed = [] + :g/^x /call add(l:completed, getline(line(".")))|d + call s:AppendToFile(l:done_file, l:completed) endfunction " Mappings {{{1 @@ -57,6 +82,74 @@ if !hasmapto("s",'n') nnoremap