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

Re: does vi has a funtion like "grep -v"?

Expand Messages
  • skyworld
    Thanks for all of your kind reply. I will check these ways. ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply
    Message 1 of 10 , Jan 26, 2013
    • 0 Attachment
      Thanks for all of your kind reply. I will check these ways.

      On Jan 25, 5:26 pm, Jiantao Wu <4576211...@...> wrote:
      > No, it does not. You can use '?' or '/' to search.
      >
      > 2013/1/25 skyworld <chenyong20...@...>
      >
      >
      >
      > > Hi,
      >
      > > does vi has a fuction like "grep -v"? I always found I need to seach
      > > within the file with those lines which exclue specific strings.
      > > Thanks.
      >
      > > regards
      >
      > > --
      > > --
      > > 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, visithttp://www.vim.org/maillist.php- Hide quoted text -
      >
      > - Show quoted text -

      --
      --
      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
    • Ping
      Why not just use external grep in vim if that s what you want? ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your
      Message 2 of 10 , Jan 26, 2013
      • 0 Attachment
        Why not just use external grep in vim if that's what you want?
        :[range]!grep -v



        On Jan 25, 2013, at 7:20 AM, Catalin Ciurea <catalin.ciurea@...> wrote:

        > On Friday, January 25, 2013 11:21:37 AM UTC+2, skyworld wrote:
        >> Hi,
        >>
        >>
        >>
        >> does vi has a fuction like "grep -v"? I always found I need to seach
        >>
        >> within the file with those lines which exclue specific strings.
        >>
        >> Thanks.
        >>
        >>
        >>
        >>
        >>
        >> regards
        >
        > See the :grep command (:he :grep) in Vim.
        > This command uses the 'grepprg' option to check what program to call. By default is 'grep -n'(See :he 'grepprg')
        >
        > You can always do something like:
        > set grepprg+=-v
        > :grep foo *
        >
        > Check :vimgrep command also. It uses Vim regular expressions and an internal search engine. (Slower but if you are familiar with Vim re, it's a good option)
        >
        > --
        > --
        > 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 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
      • Ben Fritz
        ... This will replace all the lines in [range] with the output of !grep. I don t think the OP wanted to DELETE the lines, just find them. The better way to
        Message 3 of 10 , Jan 26, 2013
        • 0 Attachment
          On Saturday, January 26, 2013 10:34:32 AM UTC-6, ping wrote:
          > Why not just use external grep in vim if that's what you want?
          >
          > :[range]!grep -v
          >
          >

          This will replace all the lines in [range] with the output of !grep. I don't think the OP wanted to DELETE the lines, just find them.

          The better way to invoke external grep for searching from Vim is with Vim's :grep command, which invokes 'grepprg' and then populates the quickfix list. 'grepprg' by default just uses grep.

          --
          --
          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
        • ping
          ... that s a good point, but from what my experiences (test, errors), in an attempt to find the solution for this desire , I really think the external grep way
          Message 4 of 10 , Jan 26, 2013
          • 0 Attachment
            On 1/26/2013 11:38 AM, Ben Fritz wrote:
            > On Saturday, January 26, 2013 10:34:32 AM UTC-6, ping wrote:
            >> Why not just use external grep in vim if that's what you want?
            >>
            >> :[range]!grep -v
            >>
            >>
            > This will replace all the lines in [range] with the output of !grep. I don't think the OP wanted to DELETE the lines, just find them.
            >
            > The better way to invoke external grep for searching from Vim is with Vim's :grep command, which invokes 'grepprg' and then populates the quickfix list. 'grepprg' by default just uses grep.
            >
            that's a good point, but from what my experiences (test, errors), in an
            attempt to find the solution for this desire , I really think the
            external grep way is the most efficient.
            reason:

            1) most of time , I just want to quicky find out the wanted or
            not-wanted (-v) lines per keyword
            2) :[range]!grep [-v] will re-use whatever your skills of standard unix
            tool : grep
            3) if you don't want to "replace" but to "display", you can use
            :[range]w !grep [-v]
            4) but the :[range]w ! way doesn't know "scale", as the new found texts
            won't but put in a buffer by default, (unless redirected), so you can't
            re-fine your research based on the result.
            5) even if you don't want to "replace" the original texts, you can
            easily go back via "u"
            6) and if you like what you get, but want to even re-define a new
            search based on it, just repeat the whole process recursively.
            7) and once done, always just recover back to original text via some
            'u'ndos.

            I also like the vimgrep coming with the fancy quickfix list, but that
            looks a better usage scenario when I need to search from a bunch of
            files (under a common dir ).

            just my 2 cents.

            regards
            ping

            --
            --
            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.