0

I'd like to have the timestamp inserted on a new line every time I open a certain file.

I see that put =strftime('%c') is the command that I want, and that putting that command into a file, say pjf.vim - and then into the folder .vim/ftplugin/ should do the trick. But unfortunately, it doesn't.

autocmd almost does what I want - but with :

autocmd VimEnter *.pjf pu=strftime('%c') - it puts the timestamp at the top of the file...

Anyone have any clues?

  • Have you looked into autocmds at all? That'd be the way I would go about something like this. – Tumbler41 Apr 24 '17 at 16:36
  • yeah I was just about to edit and say that autocmd is almost doing it - but not quite... – rm-vanda Apr 24 '17 at 16:42
  • You want it on the last line? – Tumbler41 Apr 24 '17 at 16:52
1

You were very close. You just need to add $ to your put command.

autocmd VimEnter *.pjf $pu=strftime('%c')

put can take a line argument. This can be a line number or $ for end of file.

See :help :put for more info.

  • Awesome! I wound using a little function, but this is better/cleaner. – rm-vanda Apr 24 '17 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.