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

error doing search using :grep or findstr

Expand Messages
  • dapio
    If I run findstr from a cmd prompt, I can see that if you give it no parameters, then it says bad command.. And if you give it a pattern and no file or stdin,
    Message 1 of 4 , Sep 14, 2013
    View Source
    • 0 Attachment
      If I run findstr from a cmd prompt, I can see that if you give it no parameters, then it says bad command.. And if you give it a pattern and no file or stdin, then it tries to take from stdin

      C:\>"c:\Program Files (x86)\Vim\vim74\vim"

      C:\>
      C:\>
      C:\>findstr
      FINDSTR: Bad command line

      C:\>findstr there
      dsfsdf
      dsfds

      C:\>


      When in VIM,
      e.g. I open a cmd prompt and run
      C:\Program Files (x86)\Vim\vim74>vim.exe

      I write some text dfdsfdsfsdfsdfsdfsds__there_dfsdfdsfdsfdsfsd

      and do

      :grep there

      then it exits back to the cmd prompt and tries to read stdin until I Ctrl-C

      http://i.imgur.com/ES5yHea.png


      Why can't it read what is in VIM?

      --
      --
      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/groups/opt_out.
    • Ben Fritz
      ... Because, the :grep command is what Vim uses to search files. You still need to provide the files to search. See
      Message 2 of 4 , Sep 14, 2013
      View Source
      • 0 Attachment
        On Saturday, September 14, 2013 8:37:38 AM UTC-5, dapio wrote:
        > If I run findstr from a cmd prompt, I can see that if you give it no parameters, then it says bad command.. And if you give it a pattern and no file or stdin, then it tries to take from stdin
        >
        > C:\>"c:\Program Files (x86)\Vim\vim74\vim"
        >
        > C:\>
        > C:\>
        > C:\>findstr
        > FINDSTR: Bad command line
        >
        > C:\>findstr there
        > dsfsdf
        > dsfds
        >
        > C:\>
        >
        >
        > When in VIM,
        > e.g. I open a cmd prompt and run
        > C:\Program Files (x86)\Vim\vim74>vim.exe
        >
        > I write some text dfdsfdsfsdfsdfsdfsds__there_dfsdfdsfdsfdsfsd
        >
        > and do
        >
        > :grep there
        >
        > then it exits back to the cmd prompt and tries to read stdin until I Ctrl-C
        >
        > http://i.imgur.com/ES5yHea.png
        >
        >
        > Why can't it read what is in VIM?

        Because, the :grep command is what Vim uses to search files. You still need to provide the files to search. See http://vim.wikia.com/wiki/Find_in_files_within_Vim.

        If you want to search the current file with findstr instead of Vim's built-in search, you can grep the current file:

        :grep foo %

        Note this searches the on-disk file, you would need to save first.

        Alternatively, if you don't care about using quickfix, you can write the current buffer content to stdin and see the result only in the pop-up command window:

        :w !findstr foo

        Or, filter the buffer through findstr, replacing the buffer contents with the result:

        :%!findstr foo

        --
        --
        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/groups/opt_out.
      • dapio
        On Saturday, September 14, 2013 8:07:08 PM UTC+1, Ben Fritz wrote: ... When I write a file, save it as e.g. ~/d.dd do :grep there % It then exits
        Message 3 of 4 , Sep 14, 2013
        View Source
        • 0 Attachment
          On Saturday, September 14, 2013 8:07:08 PM UTC+1, Ben Fritz wrote:
          <snip>
          > If you want to search the current file with findstr instead of Vim's built-in search, you can grep the current file:
          >
          > :grep foo %
          >
          > Note this searches the on-disk file, you would need to save first.
          >

          When I write a file, save it as e.g. ~/d.dd

          do :grep there %

          It then exits back to the shell where I had launched vim and the shell then says

          So it adds the "Shell returned 1" line and the "Press ENTER line"

          "C:\Program Files (x86)\Vim\vim74>vim

          shell returned 1

          Press ENTER or type command to continue"


          If I press ENTER it adds these lines

          "(1 of 1): FINDSTR: Cannot open d.dd
          Press ENTER or type command to continue"

          that last line is in green, if I push ENTER it goes back into VIM.






          > Alternatively, if you don't care about using quickfix, you can write the current buffer content to stdin and see the result only in the pop-up command window:
          >
          > :w !findstr foo

          that line works

          >
          > Or, filter the buffer through findstr, replacing the buffer contents with the result:
          >
          > :%!findstr foo

          yep, that does as you state I see that when the pattern is there it leaves it, and when it isn't there it wipes the buffer.

          so I can't get the :grep there % to work, even when the file is saved






          --
          --
          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/groups/opt_out.
        • Ben Fritz
          ... Works fine for me. I had to set noshellslash first but this is the default setting. ... Did the file actually save? This is a strange error since it is
          Message 4 of 4 , Sep 14, 2013
          View Source
          • 0 Attachment
            On Saturday, September 14, 2013 4:12:34 PM UTC-5, dapio wrote:
            > On Saturday, September 14, 2013 8:07:08 PM UTC+1, Ben Fritz wrote:
            > <snip>
            > > If you want to search the current file with findstr instead of Vim's built-in search, you can grep the current file:
            > >
            > > :grep foo %
            > >
            > > Note this searches the on-disk file, you would need to save first.
            > >
            >
            > When I write a file, save it as e.g. ~/d.dd
            >
            > do :grep there %
            >
            > It then exits back to the shell where I had launched vim and the shell then says
            >
            > So it adds the "Shell returned 1" line and the "Press ENTER line"
            >
            > "C:\Program Files (x86)\Vim\vim74>vim
            >
            > shell returned 1
            >
            > Press ENTER or type command to continue"
            >

            Works fine for me. I had to set 'noshellslash' first but this is the default setting.

            >
            > If I press ENTER it adds these lines
            >
            > "(1 of 1): FINDSTR: Cannot open d.dd
            > Press ENTER or type command to continue"
            >

            Did the file actually save? This is a strange error since it is already open in a buffer...

            > that last line is in green, if I push ENTER it goes back into VIM.

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