diff options
| -rw-r--r-- | projects/aodocs.vim | 29 | 
1 files changed, 20 insertions, 9 deletions
| diff --git a/projects/aodocs.vim b/projects/aodocs.vim index b965ce4..971d3c8 100644 --- a/projects/aodocs.vim +++ b/projects/aodocs.vim @@ -90,13 +90,24 @@ endfunction  function! s:TodoCopyLast() -	" Copy the last entry to the bottom -	?\n\n\d?,$t$ - -	" Move to date line -	?\n\n\zs\d? - -	" Increment day, then put the current entry at the top of the window -	call setline('.', strftime('%Y.%m.%d:')) -	execute "normal! zt2\<C-e>" +	try +		" Copy the last entry to the bottom +		?\n\n\d?,$t$ + +	" We only have a single entry (pattern not found error). +	catch /^Vim\%((\a\+)\)\?:E486: .*\\n\\n\\d/ +		" Add two lines to the end of the file. +		call append('$', ['', '']) + +		" Copy the only entry to the bottom. +		0,$-2t$ + +	finally +		" Move to date line +		?\n\n\zs\d? + +		" Increment day, then put the current entry at the top of the window +		call setline('.', strftime('%Y.%m.%d:')) +		execute "normal! zt2\<C-e>" +	endtry  endfunction | 
