Loading ...
Sorry, an error occurred while loading the content.

Re: Set variable to shell command output

Expand Messages
  • Aarto Matti
    ... I didn t know about that function, though I was interested in general solution as well. ... This is it. Thank you all a lot! -- You received this message
    Message 1 of 4 , Dec 1, 2009
    • 0 Attachment
      On Mon, Nov 30, 2009 at 7:56 PM, sc <toothpik@...> wrote:
      just wondering:  would you still want to do that if you knew vim
      supports its own strftime function?

         :let td = strftime("%Y-%b-%d")

      will give you a nice 11 character string in 'td', and you can
      adjust to your preferences

      I didn't know about that function, though I was interested in general solution as well.

      On Mon, Nov 30, 2009 at 9:05 PM, Gary Johnson <garyjohn@...> wrote:
      As sc wrote, strftime() is a better solution in this case.  However,
      for commands for which Vim does not have an internal equivalent, use
      system(), e.g.,

         let stamp = system("date +%s")

      That will include the trailing newline in your stamp variable.  If
      that's undesirable, use this instead:

         let stamp = substitute(system("date +%s"), '\n', '', '')


      This is it.

      Thank you all a lot!

      --
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.