aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/html.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-01 22:33:01 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-01 22:33:01 +1200
commit09d180ee3c798928535c5a0d0677594605652b9a (patch)
tree954108c16afc17b7732d505a1261640d73d7e048 /vim/autoload/html.vim
parentAdd new html/timestamp.vim ftplugin (diff)
downloaddotfiles-09d180ee3c798928535c5a0d0677594605652b9a.tar.gz
dotfiles-09d180ee3c798928535c5a0d0677594605652b9a.zip
Merge HTML timestamp into after/ftplugin/html.vim
I don't see myself breaking this out into its own ftplugin, and the Makefile can be simpler this way.
Diffstat (limited to 'vim/autoload/html.vim')
-rw-r--r--vim/autoload/html.vim17
1 files changed, 17 insertions, 0 deletions
diff --git a/vim/autoload/html.vim b/vim/autoload/html.vim
index f46b323f..c3d99706 100644
--- a/vim/autoload/html.vim
+++ b/vim/autoload/html.vim
@@ -13,3 +13,20 @@ function! html#UrlLink() abort
normal! a</a>
endfunction
+
+" Update a timestamp
+function! html#TimestampUpdate() abort
+ if !&modified
+ return
+ endif
+ let l:cv = winsaveview()
+ call cursor(1,1)
+ let l:li = search('\C^\s*<em>Last updated: .\+</em>$', 'n')
+ if l:li
+ let l:date = substitute(system('date -u'), '\C\n$', '', '')
+ let l:line = getline(l:li)
+ call setline(l:li, substitute(l:line, '\C\S.*',
+ \ '<em>Last updated: '.l:date.'</em>', ''))
+ endif
+ call winrestview(l:cv)
+endfunction