On 2009-11-22, Tarlika Elisabeth Schmitz wrote:
> I would like to insert the output of a command at cursor position
> (either in normal or insert mode) and map the key sequence for this.
> 
> before
> text1 text2 
> 
> after
> text1 31/12/2009 text2
> 
> 
> command:
> :r ! zenity --calendar

To insert the result of an expression at the cursor position in
insert mode, see

    :help i_CTRL-R_=

The expression could be a vim built-in function such as strftime(),
which would give you the date, e.g.,

    strftime("%d/%m/%Y")

or system(), which could be used to execute an external command such
as zenity, e.g.,

    system("zenity --calendar")

Unfortunately, the output of system() includes the trailing newline
of the command's output.  You can use substitute to fix that:

    substitute(system("zenity --calendar"), "\n", "", "")

Here's a command that will map that to F4:

    :imap <F4> <C-R>=substitute(system("zenity --calendar"), "\n", "", "")<CR>

Regards,
Gary



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to