Skip to content

Commit d500f7f

Browse files
committed
Merge branch 'auto_date_insertion' into dev
2 parents 5d2e75f + cc3638b commit d500f7f

File tree

3 files changed

+53
-6
lines changed

3 files changed

+53
-6
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,21 @@ function! VimTodoListsCustomMappings()
178178
endfunction
179179
```
180180

181+
##### Automatic date insertion
182+
183+
Automatic date insertion may be enabled by setting the following in `.vimrc`:
184+
185+
```
186+
let g:VimTodoListsDatesEnabled = 1
187+
```
188+
189+
Date format may be changed by setting the format variable to a valid
190+
`strftime()` string:
191+
192+
```
193+
let g:VimTodoListsDatesFormat = "%a %b, %Y"
194+
```
195+
181196
Future features
182197
---------------
183198

@@ -241,10 +256,12 @@ Changelog
241256

242257
#### 0.7.0
243258

244-
* Makes items list markdown compatible
245-
* Adds mappings for fast increasing/decreasing indent
259+
* Added automatic date insertion feature
260+
* Items list are made markdown compatible
261+
* Added mappings for fast increasing/decreasing indent
246262

247263
Credits
248264
-------
249265

250266
* Alexander Serebryakov, author ([GitHub](https://github.com/aserebryakov))
267+
* Jake Mason, automatic date insertion ([GitHub](https://github.com/jakemason))

doc/vim-todo-lists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,19 @@ Normal editing mode
194194
* <Space> - toggle current item
195195
* <leader>e - switch to item editing mode
196196

197+
198+
Automatic date insertion
199+
------------------------
200+
201+
Automatic date insertion may be enabled by setting the following in .vimrc:
202+
203+
let g:VimTodoListsDatesEnabled = 1
204+
205+
Date format may be changed by setting the format variable to a valid
206+
strftime() string:
207+
208+
let g:VimTodoListsDatesFormat = "%a %b, %Y"
209+
197210
==============================================================================
198211
4. Future Features *VimTodoListsFutureFeatures*
199212

@@ -277,13 +290,15 @@ SOFTWARE.
277290

278291
0.7.0
279292

280-
* Makes items list markdown compatible
281-
* Adds mappings for fast increasing/decreasing indent
293+
* Added automatic date insertion feature
294+
* Items list are made markdown compatible
295+
* Added mappings for fast increasing/decreasing indent
282296

283297
==============================================================================
284298
8. Credits *VimTodoListsCredits*
285299

286300
* Alexander Serebryakov (author) https://github.com/aserebryakov
301+
* Jake Mason (automatic date insertion) https://github.com/jakemason
287302

288303
==============================================================================
289304
# vim:tw=78:ts=8:ft=help:norl:

plugin/vim-todo-lists.vim

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
" Initializes plugin settings and mappings
2525
function! 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,13 @@ function! VimTodoListsSetItemMode()
335344
inoremap <buffer> <S-Tab> <ESC>:VimTodoListsDecreaseIndent<CR>A
336345
endfunction
337346

347+
" Appends date at the end of the line
348+
function! VimTodoListsAppendDate()
349+
if(g:VimTodoListsDatesEnabled == 1)
350+
let l:date = strftime(g:VimTodoListsDatesFormat)
351+
execute "s/$/ (" . l:date . ")"
352+
endif
353+
endfunction
338354

339355
" Creates a new item above the current line
340356
function! VimTodoListsCreateNewItemAbove()
@@ -349,7 +365,6 @@ function! VimTodoListsCreateNewItemBelow()
349365
startinsert!
350366
endfunction
351367

352-
353368
" Creates a new item in the current line
354369
function! VimTodoListsCreateNewItem()
355370
normal! 0i- [ ]

0 commit comments

Comments
 (0)