diff --git a/README.markdown b/README.markdown index 0fb9cbe..48b5f95 100644 --- a/README.markdown +++ b/README.markdown @@ -17,11 +17,11 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. `-k` : Increase the priority of the current line -`-a` : Add the priority (A) to the current line +`-a` : Set the priority of the current line to (A) -`-b` : Add the priority (B) to the current line +`-b` : Set the priority of the current line to (B) -`-c` : Add the priority (C) to the current line +`-c` : Set the priority of the current line to (C) `-d` : Insert the current date diff --git a/doc/todo.txt b/doc/todo.txt index 5a52250..f09569b 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -13,11 +13,11 @@ COMMANDS *todo-commands* `-k` : Increase the priority of the current line -`-a` : Add the priority (A) to the current line +`-a` : Set the priority of the current line to (A) -`-b` : Add the priority (B) to the current line +`-b` : Set the priority of the current line to (B) -`-c` : Add the priority (C) to the current line +`-c` : Set the priority of the current line to (C) `-d` : Insert the current date diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index 247ded6..5465c8d 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -83,21 +83,40 @@ endif " Increment and Decrement The Priority :set nf=octal,hex,alpha +function! TodoTxtGetPriority() + if match(getline('.'), '^(\w)') == 0 + let l:priority = strpart(getline('.'), 1, 1) + elseif match(getline('.'), '^x') == 0 + let l:priority = 'x' + endif + + return l:priority +endfunction + function! TodoTxtPrioritizeIncrease() - normal! 0f)h + if TodoTxtGetPriority() != '' + normal! 0f)h + endif endfunction function! TodoTxtPrioritizeDecrease() - normal! 0f)h + if TodoTxtGetPriority() != '' + normal! 0f)h + endif endfunction function! TodoTxtPrioritizeAdd (priority) - " Need to figure out how to only do this if the first visible letter in a line is not ( :call TodoTxtPrioritizeAddAction(a:priority) endfunction function! TodoTxtPrioritizeAddAction (priority) - execute "normal! mq0i(".a:priority.") \`q" + if TodoTxtGetPriority() == '' + execute "normal! mq0i(".a:priority.") \`q" + elseif TodoTxtGetPriority() == 'x' + execute "normal! mq0s(".a:priority.")\`q" + else + execute "normal! mq03s(".a:priority.")\`q" + endif endfunction if !hasmapto("j",'n')