Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make <leader>a replace set priority, even if it's already set #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.

`<leader>-k` : Increase the priority of the current line

`<leader>-a` : Add the priority (A) to the current line
`<leader>-a` : Set the priority of the current line to (A)

`<leader>-b` : Add the priority (B) to the current line
`<leader>-b` : Set the priority of the current line to (B)

`<leader>-c` : Add the priority (C) to the current line
`<leader>-c` : Set the priority of the current line to (C)

`<leader>-d` : Insert the current date

Expand Down
6 changes: 3 additions & 3 deletions doc/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ COMMANDS *todo-commands*

`<leader>-k` : Increase the priority of the current line

`<leader>-a` : Add the priority (A) to the current line
`<leader>-a` : Set the priority of the current line to (A)

`<leader>-b` : Add the priority (B) to the current line
`<leader>-b` : Set the priority of the current line to (B)

`<leader>-c` : Add the priority (C) to the current line
`<leader>-c` : Set the priority of the current line to (C)

`<leader>-d` : Insert the current date

Expand Down
27 changes: 23 additions & 4 deletions ftplugin/todo.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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.") \<esc>`q"
if TodoTxtGetPriority() == ''
execute "normal! mq0i(".a:priority.") \<esc>`q"
elseif TodoTxtGetPriority() == 'x'
execute "normal! mq0s(".a:priority.")\<esc>`q"
else
execute "normal! mq03s(".a:priority.")\<esc>`q"
endif
endfunction

if !hasmapto("<leader>j",'n')
Expand Down