Tuesday, September 10, 2019

Re: Execute command and insert its standard output at the beginning of non-empty line?


On Tue, Sep 10, 2019 at 7:32 AM 'Ottavio Caruso' via vim_use <vim_use@googlegroups.com> wrote:
Hi all,

I have this bash alias:
alias my-date='date +"%A %d %B %Y"'

and this line in vimrc:
set shellcmdflag=-ic

I want to insert (prepend) a timestamp at the beginning of a non-empty
line, without line breaks, but if I type:

:r !my-date

this will print the timestamp on the next line, that is the line below
the cursor.

Is there a way to achieve what I want?

Thanks

--
Ottavio Caruso

--
 
I recently set up a map like this:
map <leader>H :exec 'norm i' . system("echo -n 'Chronicle Herald, '") . system("date +'%A, %B %d, %Y'")<cr>

 Perhaps you could experiment with that idea?

--
John Cordes

No comments: