Permalink
Browse files

shortcuts to move forward/back through logs.

  • Loading branch information...
1 parent 225e822 commit 49a8d2709b134a8470513d1ec40d79daffb47298 @daveray committed Sep 7, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 plugin/notes.vim
View
@@ -66,3 +66,22 @@ nmap <silent> <Leader>nt a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
" Insert inline timestamp
nmap <silent> <Leader>nT i<C-R>=strftime("[%Y-%m-%d %a %I:%M %p]")<Esc>
+function! AdjustDate(date, offset)
+python << EOF
+import vim
+import datetime
+
+result = datetime.datetime.strptime(vim.eval("a:date"), "%Y-%m-%d") + \
+ datetime.timedelta(days=int(vim.eval("a:offset")))
+vim.command("let l:result = '" + result.strftime("%Y-%m-%d") + "'")
+EOF
+return result
+endfunction
+
+function! NextLog(offset)
+ execute "edit ~/.notes/log/" . AdjustDate(expand("%:t:r"), a:offset) . ".txt"
+endfunction
+
+" Move forward back through logs
+nmap <silent> <Leader>n- :execute NextLog(-1) <cr>
+nmap <silent> <Leader>n= :execute NextLog(1) <cr>

0 comments on commit 49a8d27

Please sign in to comment.