sponsor Vim development Vim logo Vim Book Ad

vimgrep.vim : Editing utilities using grep/find without external grep/find programs

 script karma  Rating 17/9, Downloaded by 2980    Comments, bugs, improvements  Vim wiki

created by
Dave Silvia
script type
grep/find utility wholly contained in Vim.  Commands implemented specifically to aid the editing task, not just find pattern matches.  Vimgrep() provides grep utility without an external grep type program.  It includes :help documentation grep-ing, selective or mass editing of files with matches, and display of output to command line or a named buffer.  Vimfind() provides find utility without an external find type program and offers same selective/mass editing as Vimgrep(). See doc directory in package for various documentation file formats and select one for more information.
install details
NOTE:  REQUIRES vsutil_vim.zip http://www.vim.org/scripts/script.php?script_id=1056
Unzip into your .vim|vimfiles directory.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vimgrep.zip 3.2 2004-09-01 6.0 Dave Silvia Version 3.2
    -  VimfindEdit/EditVimfind()
       operates the same as
       VimgrepEditDel functionality
       also applies.
vimgrep_vim.zip 3.1 2004-08-19 6.0 Dave Silvia Version 3.1
   -  Rewrote s:vimGrep() for
      search optimization.
vimgrep_vim.zip 3.0 b 2004-08-13 6.0 Dave Silvia decoupled vsutil.vim
decoupled curBuf.vim
these are now separate packages
vimgrep_vim.zip 3.0 2004-08-10 6.0 Dave Silvia Version 3.0
   -  Rewrote to change optional
      arguments to switches instead
      of positional arguments.
      Simplifies usage.
   -  Changed documentation to
      reflect same.
   -  Some minor code clean up
   -  Removed use of dummy file
      for empty Vim session.
vimgrep_vim.zip 2.2 2004-08-08 6.0 Dave Silvia Version 2.2
   -  Inappropriate inclusion of
      command/function arguments.
   -  Added BuiltInHelp
   -  Added VimfindToBuf
   -  Added VimfindList
   -  Added VimgrepList
   -  Added VimgrepHelpList
   -  Added Command/Function Help
      menu/mapped '??'

      Vim[find|grep]List opens a
      buffer listing file name
      results from the respective
      function.  Then simply cursor
      to a line in the list, and
      press 'o' to open the listed
      file in an edit buffer.
vimgrep_vim.zip 2.1 2004-08-03 6.0 Dave Silvia Many's the slip
Twixt cup and lip

Somehow the wrong version
got put into the zip
This is the corrected one
vimgrep_vim.zip 2.1 2004-08-03 6.0 Dave Silvia Version 2.1
   -  echo-ed results scrolling off
      command line by adding Pause()
   -  problem with file argument
      being '/' would append '/*' to
      search which always failed.
      Now only appends extra '/' if
      file argument does not end in
      '/' or ''.
   -  Stopped search after first match
      if FNonly.  Do no search at all
      if srchpat == '\%$'
   -  Added Vimfind
      (inspired by email from
        Hari Krishna Dara)
vimgrep_vim.zip 2.0 2004-08-01 6.0 Dave Silvia Version 2.0
  Changed script name to vimgrep.vim
  Introduced naming convention for
  commands and functions.  Commands
  begin Vimgrep[\w*], functions and
  variables begin [\w*]Vimgrep

  Function MiniVimGrep() obsoleted.
  Replaced with Vimgrep().
  Wrapper exists to maintain
  backward compatibility.

   -  Added opening of edit buffers
      for successfully grep-ed files.
   -  Added help files grep-ing.
   -  Added delete of edit/help
   -  Added gvim menu/toolbar items
      and key mappings for deleting.
   -  Included documentation files.
   -  rewrote, beefed up, made more
      robust, and otherwise enhanced.
minigrep.vim 1.1 2004-07-20 6.0 Dave Silvia The two public functions are:

     MiniVimGrep(pattern,file(s),[match case],[file names only])
     BufMiniGrep(pattern,[match case],[file names only])

where optional

      'match case' is zero or non-zero
      'file names only' is zero or non-zero

MiniVimGrep() operates on file(s) arguments and BufMiniGrep() operates on open buffers.

Version 1.1
  For grep-ing in open buffers:
   -  Added BufMiniGrep for grep-ing all open buffers
   -  Added code to set cursor to line 1, col 1 in the file in case it is
      being done with open buffers.  Then the cursor is set back to its
      original position.
   -  Added code to allow passing '%' or '' for file, meaning current buffer
   -  Added augroup and autocmd to save the buffer number so it can be used
      to return to the original buffer if grep-ing in open buffers

  For multiple files
   -  Added code to check for comma and newline file name separators.
      Comma allows the user to specify 'file' argument as
      "file1,file2,...", while newline allows 'file' argument to be
      something like glob(expand("%:p:h")."/*") or
   -  Added code to check if file is the same as the original open
      buffer, if so, don't do bdelete.
   -  Added second optional argument for returning file names only.
      If non-zero, just return file names, not the matching lines.

   -  Added code to test for empty files
   -  Added code to test for directories
minigrep.vim 1.0 2004-07-19 6.0 Dave Silvia Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo