add mdxUpdateDate() to misc
This commit is contained in:
parent
0d72136ffd
commit
26c91a6c52
1 changed files with 21 additions and 0 deletions
21
misc.vim
Normal file
21
misc.vim
Normal file
|
@ -0,0 +1,21 @@
|
|||
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
|
Loading…
Reference in a new issue