21 lines
621 B
VimL
21 lines
621 B
VimL
func s:mdxUpdateDate()
|
|
" guard ---
|
|
if getline(1) != "---" | return | endif
|
|
" find end ---
|
|
let lineEnd = search('\v%>1l^---$', 'n')
|
|
if lineEnd == 0 | return | endif
|
|
" prepare
|
|
let now = strftime('%Y/%m/%d(%a) %H:%M:%S')
|
|
let patpfx = '\v%>1l%<'.lineEnd.'l'
|
|
" createdAt
|
|
let line = search(patpfx.'^createdAt:\s*$', 'n')
|
|
if line > 0 | call setline(line, 'createdAt: '.now) | endif
|
|
" createdAt
|
|
let line = search(patpfx.'^updatedAt:', 'n')
|
|
if line > 0 | call setline(line, 'updatedAt: '.now) | endif
|
|
endfunc
|
|
|
|
augroup sup39_vimrc_misc
|
|
au!
|
|
au BufWritePre *.mdx call <SID>mdxUpdateDate()
|
|
augroup END
|