mirror of
https://github.com/freitass/todo.txt-vim.git
synced 2025-11-08 09:53:48 -05:00
Resolves #17
This commit is contained in:
@@ -31,7 +31,7 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
|
||||
|
||||
`<leader>-X` : Mark all tasks as completed
|
||||
|
||||
`<leader>-D` : Remove completed tasks
|
||||
`<leader>-D` : Move completed tasks to done.txt
|
||||
|
||||
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
|
||||
|
||||
@@ -27,6 +27,6 @@ COMMANDS *todo-commands*
|
||||
|
||||
`<leader>-X` : Mark all tasks as completed
|
||||
|
||||
`<leader>-D` : Remove completed tasks
|
||||
`<leader>-D` : Move completed tasks to done.txt
|
||||
|
||||
<leader> is \ by default, so <leader>-s means you type \s
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
2014-11-01 Find a way to import text into markdown and vim doc @doc
|
||||
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
|
||||
@@ -35,8 +35,33 @@ function! TodoTxtMarkAllAsDone()
|
||||
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()
|
||||
function! TodoTxtRemoveCompleted()
|
||||
" 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user