Tuesday, June 23, 2020

Re: Date in a boilerplate file

> I know how to insert date from command line, but is it possible to embed
> the command in the boilerplate file and have it transformed into the real
> date?

In order to keep track of file versions, I have a .vimrc file that updates
a timestamp every time the file is saved. That sounds similar to this
problem.

I've attached the complete file, but in case that has the problem, here's
the text:

" .vimrc with timestamp

function! UpdateTimestamp () " Note silent! suppresses error message if
" no matching string found
silent! '[,']s/^[#\"] End.*Last changed: \zs.*/\= strftime("%Y-%m-%d
%H:%M:%S") /

endfunction

augroup TimeStamping
autocmd!

autocmd BufWritePre,FileWritePre,FileAppendPre * :call
UpdateTimestamp()
augroup END

:set expandtab
:set tabstop=3

" End .vimrc Last changed: 2019-08-22 15:43:18

As you can see, the .vimrc itself uses the technique.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5fadb327a881c23be100b084a82f404b.squirrel%40webmail.vybenetworks.com.

No comments:

Post a Comment