2424" Initializes plugin settings and mappings
2525function ! VimTodoListsInit ()
2626 set filetype = todo
27+
28+ if ! exists (' g:VimTodoListsDatesEnabled' )
29+ let g: VimTodoListsDatesEnabled = 0
30+ endif
31+
32+ if ! exists (' g:VimTodoListsDatesFormat' )
33+ let g: VimTodoListsDatesFormat = " %X, %d %b %Y"
34+ endif
35+
2736 setlocal tabstop = 2
2837 setlocal shiftwidth = 2 expandtab
2938 setlocal cursorline
@@ -325,7 +334,7 @@ function! VimTodoListsSetItemMode()
325334 nnoremap <buffer> k :VimTodoListsGoToPreviousItem<CR>
326335 nnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
327336 vnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
328- inoremap <buffer> <CR> <CR><ESC> :VimTodoListsCreateNewItem<CR>
337+ inoremap <buffer> <CR> <ESC> :call VimTodoListsAppendDate() <CR> A < CR><ESC> :VimTodoListsCreateNewItem<CR>
329338 noremap <buffer> <leader> e :silent call VimTodoListsSetNormalMode()<CR>
330339 nnoremap <buffer> <Tab> :VimTodoListsIncreaseIndent<CR>
331340 nnoremap <buffer> <S-Tab> :VimTodoListsDecreaseIndent<CR>
@@ -335,6 +344,12 @@ function! VimTodoListsSetItemMode()
335344 inoremap <buffer> <S-Tab> <ESC> :VimTodoListsDecreaseIndent<CR> A
336345endfunction
337346
347+ function ! VimTodoListsAppendDate ()
348+ if (g: VimTodoListsDatesEnabled == 1 )
349+ let l: date = strftime (g: VimTodoListsDatesFormat )
350+ execute " s/$/ (" . l: date . " )"
351+ endif
352+ endfunction
338353
339354" Creates a new item above the current line
340355function ! VimTodoListsCreateNewItemAbove ()
@@ -349,7 +364,6 @@ function! VimTodoListsCreateNewItemBelow()
349364 startinsert !
350365endfunction
351366
352-
353367" Creates a new item in the current line
354368function ! VimTodoListsCreateNewItem ()
355369 normal ! 0 i- [ ]
0 commit comments