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

saving results of searches

Expand Messages
  • jayeola
    Looking for a string when editing a file..... ... How does one save these results somewhere? Code is slowly growing and I an tempted to write these results
    Message 1 of 4 , Oct 6, 2010
    • 0 Attachment
      Looking for a string when editing a file.....

      :%g/^function

      How does one save these results somewhere? Code is slowly growing and
      I an tempted to write these results down ;-) !!

      --
      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
    • Jürgen Krämer
      Hi, ... This will append every line that starts with function to the file my-function.lst. I removed the range (%), because for :g % is the default. This
      Message 2 of 4 , Oct 6, 2010
      • 0 Attachment
        Hi,

        jayeola wrote:
        > Looking for a string when editing a file.....
        >
        > :%g/^function
        >
        > How does one save these results somewhere? Code is slowly growing and
        > I an tempted to write these results down ;-) !!

        One possible way:

        :g/^function/.w! >> my-functions.lst

        This will append every line that starts with "function" to the file
        my-function.lst. I removed the range (%), because for :g % is the default.
        This might get slow, because on every matching line the file is opened,
        the line is written, and the file is closed. Also you have to make sure
        the file does not exist if you want to create a clean list.

        Another way:

        :redir @a
        :g/^function/
        :redir END
        :new
        :put a
        :w my-functions.lst

        This redirects the list of your functions to register @a, creates a new
        buffer, and pastes the content of register @a into the new buffer. This
        has the advantage of letting you edit the result before saving it and
        doing just one write at the end.

        Regards,
        Jürgen

        --
        Sometimes I think the surest sign that intelligent life exists elsewhere
        in the universe is that none of it has tried to contact us. (Calvin)

        --
        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
      • Tim Chase
        ... (the % limits it to the current file, but you can use a filespec instead) You can then use ... to navigate back/forwards in the list of matches or use
        Message 3 of 4 , Oct 6, 2010
        • 0 Attachment
          On 10/06/10 07:58, Jürgen Krämer wrote:
          >> :%g/^function
          >>
          >> How does one save these results somewhere? Code is slowly growing and
          >> I an tempted to write these results down ;-) !!
          >
          > One possible way:
          >
          > :g/^function/.w!>> my-functions.lst

          Another way would be to learn to use the quickfix window:

          :vimgrep /^function/ %

          (the "%" limits it to the current file, but you can use a
          filespec instead)

          You can then use

          :cn
          :cN

          to navigate back/forwards in the list of matches or use

          :copen

          to open the quickfix window where you can navigate around and
          press <enter> on the one you want. Alternatively, you can use

          :lvimgrep /^function/ %
          :lopen
          :lne
          :lN

          (though I can't readily explain the benefits/drawbacks of using
          the location-list instead of the quickfix list...I usually just
          use the QF list).

          -tim




          --
          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
        • Christian Brabandt
          Hi Tim! ... You can have several quickfix like windows open, without having the need to abandon the results from one Quickfix. regards, Christian -- You
          Message 4 of 4 , Oct 6, 2010
          • 0 Attachment
            Hi Tim!

            On Mi, 06 Okt 2010, Tim Chase wrote:

            > :lvimgrep /^function/ %
            > :lopen
            > :lne
            > :lN
            >
            > (though I can't readily explain the benefits/drawbacks of using the
            > location-list instead of the quickfix list...I usually just use the QF
            > list).

            You can have several "quickfix" like windows open, without having the
            need to abandon the results from one Quickfix.


            regards,
            Christian

            --
            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
          Your message has been successfully submitted and would be delivered to recipients shortly.