EasyGrep : Fast and Easy Find and Replace Across Multiple Files
| script karma
Downloaded by 7022
Comments, bugs, improvements
script versions (upload new version)
|EasyGrep is a plugin for performing search and replace operations through multiple files. Vim already has builtin support for searching through files with its 'vimgrep' and 'grep' commands, but EasyGrep makes using them much, much easier. It also provides a powerful "Replace in Files" operation, something that is not very easy to do in Vim by default. With EasyGrep, you can specify with high-precision exactly the type of files you want to search, whether it be all files, only open buffers, only files matching a pattern, etc. Additionally, you can easily specify searching through hidden files, case-sensitivity, performing a recursive search, and many more options that make searching more easy.
EasyGrep provides both key mappings and commands to make search and replace easy. When using EasyGrep, searching for a word is as easy as typing <leader>vv (v v, not double-u) over the word for which you want to search. This search can also be accomplished with the :Grep command and a user-specified pattern. Performing a "replace in files" is similar; type <leader>vr or use the :Replace command. Setting options is easy, simply type <leader>vo or :GrepOptions. EasyGrep provides a great set of defaults but can also be configured to start up just how you like it; see the script for these options. Most vimgrep (and grepprg) options are supported.
For an in-development version of EasyGrep go to http://github.com/dkprice/vim-easygrep
<Leader>vv - Grep for the word under the cursor, match all occurences,
<Leader>vV - Grep for the word under the cursor, match whole word, like
<Leader>va - Like vv, but add to existing list
<Leader>vA - Like vV, but add to existing list
<Leader>vr - Perform a global search search on the word under the cursor
and prompt for a pattern with which to replace it.
<Leader>vo - Select the files to search in and set grep options
Search for the specified arg, like <Leader>vv. When an ! is added,
search like <Leader>vV
Search for the specified arg, add to existing file list, as in
<Leader>va. When an ! is added, search like <Leader>vA
:Replace [target] [replacement]
Perform a global search and replace. The function searches
the same set of files a grep for the desired target and opens a dialog to
Undoes the last :Replace operation. Does not stack successive
searches; only the last replace may be undone. This function may not
work well when edits are made between a call to Replace and a call to
Open a window to set grep options.
|Copy EasyGrep.vim and EasyGrepFileAssociations to your plugin directory; copy EasyGrep.txt to your doc directory. Run helptags on your doc directory.|
Click on the package to download.
ip used for rating: 184.108.40.206
||Improved: much better support when grepprg is ack or grep. These tools can search much more quickly than vimgrep and so may be preferable to some users.
Feature: added a mapping to echo the command that EasyGrep will issue (see 'v' in the options explorer)
Feature: Added keymap toggle for EasyGrepSearchCurrentBufferDir
Fixed: command line parsing of Grep command discarded spaces
Feature: added support for grep exclusions when grepprg is grep or ack
Feature: Added EasyGrepDefaultUserPattern option. Thanks to Jesus Barcons for the suggestion.
Improved: Cleaned up the documentation
Improved: Cleaned up the internals of the script substantially
Improved: Formalized multi-select mode, which is when multiple file extensions are selected from the options explorer
Improved: lots of misc fixes
||Documentation: Added a help tag for each of the commands so that you can
look up more information on them.
Improved: Cleaned up the internals of the script substantially
Improved: Changed the name of FilterErrorList to ResultListFilter
Feature: Added ResultListOpen command to open all of the files in the
result list (aka error list)
Fixed: Added -- to signify the end of the command line options. Grepping
for patterns such as '->var' are now possible with ':Grep -- ->var'
||Highlight: The Replace and ReplaceUndo commands were reimplemented. The granularity of matches inside of a Replace call were improved so that you can now decide replacements individually per line.
Additionally, Complex operations such as replacing x[i][j][k] with x(i,j,k) and following it up with a ReplaceUndo are now possible.
Please report any regressions with either of these functions.
Feature: Added count command line option (-m 4 or -4)
Feature: Improved Grep options window keybindings; searching within the options explorer window is now possible
Feature: Expanded searches to include all of the active buffers' directories
Bugfix: Fixed recursive operation and expanded search from reporting duplicate results
Bugfix: Fixed <C-e> and <C-y> in replace mode
Feature: Added EasyGrepWindowPosition for specifying where the error list window will be opened
Feature: Added FilterErrorlist command for filtering the results within the quickfix or location list windows
Feature: Improved printout when no matches are found
Feature: Improved searching when an entire line is selected
||Feature: Expanded upon the list of file associations
Feature: Expanded searches to the current buffer's directory in addition to the current working directory
Feature: Added command line arguments to :Grep and :Replace for recursive searches and case sensitivity
Feature: Added toggle for window replace mode
Feature: Added toggle for showing file associations list in options explorer
Bugfix: Case insensitivity would fail in replacing some patterns
||Update to 0.95: Fixed an error in calling ReplaceCurrentWord identified by Eric Ho.
Feature: Added search and replace on visual selections.
Feature: Improved Grepping for items that can be interpreted as regular expressions. Selections are assumed to be literal, whereas explicit commands are assumed to be regular expressions.
Feature: Removed option g:EasyGrepNoDirectMappings in favor of g:EasyGrepOptionPrefix, which allows the option prefix to be changed.
Bugfix: The tracked extension would sometimes fail to be updated when switching between buffers
Documentation: Split the documentation into its own file; greatly expanded upon its contents.
Change: Activating a mode that is already activated will no longer deactivate it.
Change: GrepOptions no longer accepts an argument; use user mode instead.
Change: Clarified mapping names; custom mappings will need to be reset.
||Feature: Added forward slash delineated pattern to the Replace command
e.g. :Replace /target/replacement/
that allows more complicated replacements; you can now work with
patterns that have spaces in them.
Bugfix: If cursorline is off at the start of a replace, now ensuring that cursorline is turned off for all buffers, and not just the last one
Bugfix: fixed an issue with an extra tab being opened during a replacement
||Implemented case sensitivity that is independent of ignorecase; thanks to Doro Wu for contributing to this functionality
Changed shortcut key for hidden files from 'i' to 'h'
||Expanded search of EasyGrepFileAssociations list to every component of 'runtimepath'. This solves a starting message for those who placed EasyGrepFileAssociations in a location other than the first location in 'runtimepath'.
||Fixed paths with spaces in them
Folds will now be disabled where replacements are to be made
Fixed an error with checking for extra warnings
Better highlighting while replacing
Recursive mode can no longer be activated when Buffers mode is activated
||Fixed an issue with tracking the file extension where sometimes the desired extension wouldn't be registered.
Better reporting when no files match.
Now warning when searching from a working directory that doesn't match the current file's directory.
Added g:EasyGrepExtraWarnings option.
||Improved Replace and ReplaceUndo
Added two configurable modes for how the windows operate when doing a global replace.
Fixed an issue with linked filetypes.
||Added experimental :Replace and :ReplaceUndo commands; keymapped <leader>vr for :Replace
Improved response when no matches
||Added option to toggle showing fewer or more options; showing fewer options by default.
Added option '?' to print the current configuration and save it to a register.
Now creating direct mapping by default; see g:EasyGrepNoDirectMappings to turn this off.