Sunday, June 21, 2015

Re: g:timestamp_rep syntax



On Fri, Jun 12, 2015 at 4:15 AM, Christian Brabandt <cblists@256bit.org> wrote:
Hi Jacob!

On Do, 11 Jun 2015, Jacob Wegelin wrote:

> Dear Christian,
>
> On 2015-06-11 Thu 15:03, Christian Brabandt wrote:
> >Hi Jacob!
> >
> >On Do, 11 Jun 2015, Jacob Wegelin wrote:
> >
> >>The timestamp.vim plugin works beautifully. It automatically updates a line in the file that I edit, giving the second when I last re-saved the file.
> >>
> >>But how does one change the format of the timestamp?
> >>
> >>.vim/doc/timestamp.txt
> >>
> >>says, about the format:
> >>
> >>Default: '%a %d %b %Y %I:%M:%S %p %Z'
> >>
> >><snip>
> >>
> >>To change this value, either set g:timestamp_rep in your {.vimrc} or set b:timestamp_rep for the buffer in question.
> >>
> >>Can anyone provide an example of the syntax whereby one explicitly sets g:timestamp_rep in the .vimrc?
> >>
> >>For instance, I tried inserting the following line into my .vimrc
> >>
> >>set g:'%a'
> >>
> >>and this threw an error when I opened a new file in vim.
> >>
> >>Thanks for any insight
> >
> >You need to set a variable. This is done using the :let command, so you
> >have to use in your .vimrc:
> >
> >:let g:timestampe_rep='%a %b'
>
> I placed the following into my .vimrc:
>
> :let g:timestamp_rep='%Y-%m-%d %a %H:%M:%S'
>
> Then I opened a file which was initially
>
> Created: TIMESTAMP
> Modified: TIMESTAMP
>
> and when I saved it, it became
>
> Created: 2015-06-11 Thu 15:47:21
> Modified: 2015-06-11 Thu 15:47:21
>
> But when I resaved it, and later re-opened it and resaved, the
> timestamps were not updated.
>

I know I'm coming into this conversation very late, but I noticed this on the timestamp.vim vim.org page:

NOTE: If you find that on subsequent writes of the file, the second line is also unchanged, it is probably because the time returned by strftime is NOT is the format above. [Look closely and see if there is a leading 0 or timezone missing]. If you are using version 1.11 and higher and still have this problem, please report it to me. As a temporary fix, you can put the line > 

    let timestamp_regexp = '\v\C%(<Last %([cC]hanged?|[Mm]odified):\s+)@<=.*$' 

in your .vimrc. This however has the disadvantage of eating all the text after the colon in any timestamp line. 

If you still have this problem, does this help?

 
> It appears that the plugin recognizes TIMESTAMP and changes it, but
> it does not recognize the date in that format to re-change it.
>
> How could I fix this?

Have you tried contacting the author?

Best,
Christian
--
Manche drücken durch lautes Lachen ihren Enthusiasmus, z.B. über
herrliche Musik, aus.
                -- Jean Paul

--
--
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.
For more options, visit https://groups.google.com/d/optout.

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: