1 " speeddating.vim - Use CTRL-A/CTRL-X to increment dates, times, and more
2 " Maintainer: Tim Pope <http://tpo.pe/>
4 " GetLatestVimScripts: 2120 1 :AutoInstall: speeddating.vim
8 if exists("g:loaded_speeddating") || &cp || v:version < 700
11 let g:loaded_speeddating = 1
16 let g:speeddating_handlers = []
21 function! s:add_format(master,count,bang)
22 " Calls with neither argument nor count are for information,
23 " and so should be handled immediately.
24 " Call loadformats to cause autoloading to happen
25 if a:master == "" && !a:count
26 call speeddating#loadformats()
29 if exists("g:speeddating_loaded_formats")
30 " Autoloading already done pass on request immediately
31 call speeddating#adddate(a:master,a:count,a:bang)
33 " Defer handling of format specifications until autoloading is done
34 let g:speeddating_formats += [[a:master,a:count,a:bang]]
38 command! -bar -bang -count=0 -nargs=? SpeedDatingFormat :call s:add_format(<q-args>,<count>,<bang>0)
43 nnoremap <silent> <Plug>SpeedDatingUp :<C-U>call speeddating#increment(v:count1)<CR>
44 nnoremap <silent> <Plug>SpeedDatingDown :<C-U>call speeddating#increment(-v:count1)<CR>
45 vnoremap <silent> <Plug>SpeedDatingUp :<C-U>call speeddating#incrementvisual(v:count1)<CR>
46 vnoremap <silent> <Plug>SpeedDatingDown :<C-U>call speeddating#incrementvisual(-v:count1)<CR>
47 nnoremap <silent> <Plug>SpeedDatingNowLocal :<C-U>call speeddating#timestamp(0,v:count)<CR>
48 nnoremap <silent> <Plug>SpeedDatingNowUTC :<C-U>call speeddating#timestamp(1,v:count)<CR>
50 if !exists("g:speeddating_no_mappings") || !g:speeddating_no_mappings
51 nmap <C-A> <Plug>SpeedDatingUp
52 nmap <C-X> <Plug>SpeedDatingDown
53 xmap <C-A> <Plug>SpeedDatingUp
54 xmap <C-X> <Plug>SpeedDatingDown
55 nmap d<C-A> <Plug>SpeedDatingNowUTC
56 nmap d<C-X> <Plug>SpeedDatingNowLocal
60 " Default Formats {{{1
62 if exists('g:speeddating_formats')
65 let g:speeddating_formats = []
66 SpeedDatingFormat %i, %d %h %Y %H:%M:%S %z " RFC822
67 SpeedDatingFormat %i, %h %d, %Y at %I:%M:%S%^P %z " mutt default date format
68 SpeedDatingFormat %a %b %_d %H:%M:%S %Z %Y " default date(1) format
69 SpeedDatingFormat %a %h %-d %H:%M:%S %Y %z " git
70 SpeedDatingFormat %h %_d %H:%M:%S " syslog
71 SpeedDatingFormat %Y-%m-%d%[ T_-]%H:%M:%S %z
72 SpeedDatingFormat %Y-%m-%d%[ T_-]%H:%M:%S%?[Z] " SQL, etc.
73 SpeedDatingFormat %Y-%m-%d%[ T_-]%H:%M%z " date -Im
74 SpeedDatingFormat %Y-%m-%d%[ T_-]%H:%M
75 SpeedDatingFormat %Y-%m-%d
76 SpeedDatingFormat %-I:%M:%S%?[ ]%^P
77 SpeedDatingFormat %-I:%M%?[ ]%^P
78 SpeedDatingFormat %-I%?[ ]%^P
79 SpeedDatingFormat %H:%M:%S,%k " SRT file
80 SpeedDatingFormat %H:%M:%S
81 SpeedDatingFormat %B %o, %Y
82 SpeedDatingFormat %d%[-/ ]%b%1%y
83 SpeedDatingFormat %d%[-/ ]%b%1%Y " These three are common in the
84 SpeedDatingFormat %Y %b %d " 'Last Change:' headers of
85 SpeedDatingFormat %b %d, %Y " Vim runtime files
93 " vim:set et sw=2 sts=2: