Sunday, October 30, 2011

Re: open file and write current date?

On 10/27/11 18:33, Eric Maquiling wrote:
> Hi all,

I don't recall seeing a reply to this and it's been a couple days
so I'll take a rough stab at it

> vim + filename (will take me to end of the file)
> then add the current date/time (I already have iab for the current date/time
> from Guckes site)
> ..and then start to edit below that line.

You might try something like

autocmd BufRead mylog.txt sil! $put=strftime('%c')|sil! $put_
| startinsert

(all on one line) in your vimrc file. This will, upon reading in
a file named "mylog.txt" (any filename/glob will do), go to the
bottom of the file, insert the date in whatever format you choose
(I used "%c" as a default, adjust as you see fit), then put a
blank line, and start insert-mode. The "sil!" entries are there
to prevent it from verbosely telling you about the added lines.

-tim


--
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

No comments: