I am sorry that I didn't fully express my question. In short, all I want to do it to insert a string , i.e."Modified:" in the first line of a newly open file. Is that possible?
On Sep 15, 10:52 pm, Ben Fritz <[email protected]> wrote: > On Sep 15, 8:32 am, Tim Chase <[email protected]> wrote: > > > > > > > > > > > On 09/15/11 08:25, Stanley Rice wrote: > > > > I have write some code that can change the modified data. I > > > search for the first 10 line of the current file, and search > > > for the key word "Modified: ", and then replace the content > > > after the keyword with current time stamp each time I save the > > > file. I thought it's amazing. > > > > However, I have to write the same line "Modified: " every time > > > I edit a new file. what a boring and cumbersome job! So, is > > > there any ways to insert the specific line to the newly edited > > > file, thought writing some code in .vimrc? > > > While untested, I suspect it would look something like > > > autocmd BufWritePre myfile.txt > > %s/Modified:\zs.*/\=strftime("%c")/e > > I think the OP has code to do the timestamp update already, provided > the file has a timestamp line. He seems to be searching for a way to > automatically add the timestamp line to new files. > > :help skeleton has a bare-bones example of how this could be done. > > http://vim.wikia.com/wiki/Use_eval_to_create_dynamic_templatesextends > this for adding dynamic text, like pre-populating the timestamp with > the current time when creating the new file. > > There are also a great number of template/snippet plugins > available:http://vim.wikia.com/wiki/Category:Automated_Text_Insertion#Related_s... -- 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
