Thursday, July 30, 2015

Re: Flexible auto-insertion of date at end of file.

On 30.07.15 20:30, Erik Christiansen wrote:
> Desired Enhancement:
...

Changing to named parameters fails through lack of an eval/expand on the
a:Format, but then also switching to strange appending syntax¹ ($put)
found on the list:

au BufWinEnter ~/Personal/rainfall/*/* call Append_Date('%d.%m: ')

function! Append_Date(Format)
normal G
" :r !date a:Format " Fails: date: invalid date `a:Format'
$put=strftime(a:Format)
normal A
endfunction

does 99% of the job, appending the date to the file, and moving the
cursor to the end of the inserted text. (I.e. half of the "normal A"
action) It still does not enter insert mode. Replacing that with a:

startinsert

finally does the job. But that took a lot of grepping through mail
archives to find and dissect related old posts. (Tried googling this
stuff, but it was all chaff - no wheat.)

¹ :h $put
E149: Sorry, no help for $put

:helpgrep " put"
E480: No match: " put"

How to find it, I wonder?

Erik

--
Abbott's Admonitions:
(1) If you have to ask, you're not entitled to know.
(2) If you don't like the answer, you shouldn't have asked the question.
- Charles Abbot, dean, University of Virginia

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