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

How can I put the output of a code in a buffer ?

Expand Messages
  • Arup Rakshit
    Say I wrote  a code :- input = [ a , b , b , b , a , a , b , c , c ] prev = 0 output = input.slice_before do |e|   input[prev = prev + 1] != e end.to_a p
    Message 1 of 5 , May 9, 2014
    • 0 Attachment
      Say I wrote  a code :-

      input = ['a','b','b','b','a','a','b','c','c']

      prev = 0
      output = input.slice_before do |e|
        input[prev = prev + 1] != e
      end.to_a

      p output

      Now when I will run - !ruby %, I want the output to come to a new separate buffer in the same tab. how to do the same ?


       
      Regards,
      Arup Rakshit

      --
      --
      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@....
      For more options, visit https://groups.google.com/d/optout.
    • Elijah Griffin
      ... Elijah -- -- 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
      Message 2 of 5 , May 9, 2014
      • 0 Attachment
        Arup Rakshit wrote:
        > Say I wrote  a code :-
        ...
        > Now when I will run - !ruby %, I want the output to come to a new
        > separate buffer in the same tab. how to do the same ?

        How about just using:

        :new
        :r!ruby #

        It's not hard to combine them into a single mapping along the lines of:

        :map #r :new|r!ruby #

        Elijah

        --
        --
        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@....
        For more options, visit https://groups.google.com/d/optout.
      • Gary Johnson
        ... There are a number of ways to do that. Here s one. ... That opens a new window above the current one, then reads the output of your program into it. See
        Message 3 of 5 , May 9, 2014
        • 0 Attachment
          On 2014-05-09, Arup Rakshit wrote:

          > Now when I will run - !ruby %, I want the output to come to a new
          > separate buffer in the same tab. how to do the same ?

          There are a number of ways to do that. Here's one.

          :new | :r !ruby %

          That opens a new window above the current one, then reads the output
          of your program into it. See

          :help :read!

          Note that the % is expanded to the name of the current buffer before
          the focus is changed to the new buffer. Note also that with this
          method there will be an extra, empty line at the top of the new
          buffer.

          Regards,
          Gary

          --
          --
          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@....
          For more options, visit https://groups.google.com/d/optout.
        • Elijah Griffin
          ... Not when I test it. I get: E499: Empty file name for % or # , only works with :p:h for VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012
          Message 4 of 5 , May 9, 2014
          • 0 Attachment
            Gary Johnson writes:
            > :new | :r !ruby %
            ...
            > Note that the % is expanded to the name of the current buffer before
            > the focus is changed to the new buffer.

            Not when I test it. I get:

            E499: Empty file name for '%' or '#', only works with ":p:h"

            for "VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:25:35)".
            Does it work differently in other versions?

            > Note also that with this method there will be an extra, empty line at
            > the top of the new buffer.

            You can change the behavior to put the line at the end of the buffer by
            specifying a line number of zero to the read command:

            :new | :0r !ruby filename

            It's difficult to regain control of a ex mode : command after a ! in
            order delete the extra line entirely, but I expect it can be done.

            Elijah

            --
            --
            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@....
            For more options, visit https://groups.google.com/d/optout.
          • Gary Johnson
            ... I see that you re right and I was wrong. I did test something, but apparently not what I wrote. Trying to do too many things at once, I guess. Using #
            Message 5 of 5 , May 9, 2014
            • 0 Attachment
              On 2014-05-09, Elijah Griffin wrote:
              > Gary Johnson writes:
              > > :new | :r !ruby %
              > ...
              > > Note that the % is expanded to the name of the current buffer before
              > > the focus is changed to the new buffer.
              >
              > Not when I test it. I get:
              >
              > E499: Empty file name for '%' or '#', only works with ":p:h"
              >
              > for "VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:25:35)".
              > Does it work differently in other versions?

              I see that you're right and I was wrong. I did test something, but
              apparently not what I wrote. Trying to do too many things at once,
              I guess.

              Using # instead of % does work, as you wrote earlier.

              Also, my use of : in front of the r was unnecessary.

              Thanks for the correction.

              Regards,
              Gary

              --
              --
              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@....
              For more options, visit https://groups.google.com/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.