├── README ├── plugin ├── EasyGrepFileAssociations └── EasyGrep.vim └── doc └── EasyGrep.txt /README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=2438 2 | 3 | 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. 4 | 5 | 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 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 vr or use the :Replace command. Setting options is easy, simply type 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. 6 | 7 | For a screencast of the script in action go here: http://downloads.veryspeedy.net/vim/EasyGrep.gif 8 | 9 | Keymappings: 10 | 11 | vv - Grep for the word under the cursor, match all occurences, 12 | like |gstar| 13 | vV - Grep for the word under the cursor, match whole word, like 14 | |star| 15 | va - Like vv, but add to existing list 16 | vA - Like vV, but add to existing list 17 | vr - Perform a global search search on the word under the cursor 18 | and prompt for a pattern with which to replace it. 19 | vo - Select the files to search in and set grep options 20 | 21 | Commands: 22 | 23 | :Grep [arg] 24 | Search for the specified arg, like vv. When an ! is added, 25 | search like vV 26 | 27 | :GrepAdd [arg] 28 | Search for the specified arg, add to existing file list, as in 29 | va. When an ! is added, search like vA 30 | 31 | :Replace [target] [replacement] 32 | Perform a global search and replace. The function searches 33 | the same set of files a grep for the desired target and opens a dialog to 34 | confirm replacement. 35 | 36 | :ReplaceUndo 37 | Undoes the last :Replace operation. Does not stack successive 38 | searches; only the last replace may be undone. This function may not 39 | work well when edits are made between a call to Replace and a call to 40 | ReplaceUndo. 41 | 42 | :GrepOptions [arg] 43 | Open a window to set grep options. 44 | -------------------------------------------------------------------------------- /plugin/EasyGrepFileAssociations: -------------------------------------------------------------------------------- 1 | " EasyGrepFileAssociations 2 | " Version 0.96 3 | " 4 | " This file is made up of Key-value pairs that associate file types 5 | " individual file extensions should only show up in one pair; behavior may be 6 | " inconsistent if they show up in several. To include filetypes in multiple 7 | " groups, you can link to a group using where key is a groupname 8 | " Note that individual file extensions need not be listed in this file if they 9 | " do not have associated file types 10 | " extensions should not be complicated regular expressions for matching to 11 | " happen correctly 12 | " TODO: consider how extensions dominate another, try this syntax 13 | " TODO: consider extension ordering for dominating 14 | " TODO: consider syntax to set exclusions 15 | " TODO: perhaps have a global exclude flag 16 | 17 | Ada=*.adb *.ads *.ada *.gpr *.ada_m *.adc 18 | Assembly=*.asm *.[sS] *.[aA] *.mac *.lst *.i 19 | B=*.mch *.ref *.imp 20 | Basic=*.vbs *.dsm *.ctl *.bas *.frm *.sba *.iba *.ibi *.fb *.bi 21 | BibTeX=*.bib *.bst 22 | C#=*.cs 23 | C++=*.cpp *.hpp *.cxx *.hxx *.cc *.hh *.c++ *.inl 24 | C=*.c *.h 25 | CUDA=*.cu *.cuh 26 | Cobol=*.cbl *.cob 27 | ColdFusion=*.cfm *.cfi *.cfc 28 | Configuration=.*rc *.conf *.cf *.cfg *.config *.ini 29 | D=*.d 30 | Diff=*.diff *.rej *.patch 31 | EDIF=*.edf *.edif *.edn *.edo 32 | Eiffel=*.[eE] 33 | Erlang=*.erl *.hrl *.yaws 34 | Forth=*.fs *.ft *.frt 35 | Fortran=*.[fF] *.for *.FOR *.fortran *.fpp *.FPP *.ftn *.FTN *.[fF]77 *.[fF]90 *.[fF]95 36 | HDL=*.hdl *.vhd *.vhdl *.vbe *.vst *.v *.va *.vams *.tdf 37 | Haskell=*.hs *.lhs *.chs 38 | Image=*.xpm *.xpm2 39 | Jam=Prl*.* JAM*.* Jamroot Jamfile *.jpl *.jpr 40 | Java=*.java *.jav *.jj *.jjt 41 | Lex=*.lex *.l *.ll 42 | Lisp=*.lsp *.lisp *.el *.cl *.jl *.L 43 | Make=*.m4 *.ac *.in *.am *[mM]akefile *.mk *.mak *.dsp 44 | Math=*.m *.asv *.mv *.mpl *.mws *.nb 45 | OCAML=*.ml *.mli *.mll *.mly 46 | ObjectiveC=*.m *.mm 47 | Oracle=*.tyb *.typ *.tyc *.pkb *.pks *.ora 48 | PHP=*.php *.phtml *.ctp 49 | Perl=*.pl *.PL *.pm *.pod 50 | PostScript=*.ps *.pfa *.afm *.eps *.epsf *.epsi *.ai *.ppd 51 | Python=*.py *.pyw 52 | Qt=*.moc *.qmake *.ui *.ts 53 | Ruby=*.rb *.rbw *.gem *.gemspec [rR]akefile *.erb *.rhtml 54 | RubyOnRails=*.builder *.rxml *.rjs 55 | SQL=*.sql *.sqlj *.msql *.mysql *.pls *.plsql *.zsql 56 | Scheme=*.scm *.ss 57 | Shell=*.sh *.bash *.ebuild *.ksh *.tcsh *.cmd *.bat 58 | Spice=*.sp *.spice *.spy *.spi 59 | Tcl=*.tcl *.tk *.itcl *.itk *.jacl 60 | TeX=*.tex *.latex *.sty *.dtx *.ltx *.bbl *.mkii *.mkiv *.texinfo *.texi *.txi 61 | Text=*.txt *.inf *.INF 62 | Vera=*.vr *.vri *.vrh 63 | Vim=*.vim .vimrc .gvimrc *.vba .exrc _exrc .vim* 64 | Virata=*.hw *.module *.pkg 65 | VisualStudioProject=*.sln *.vcproj *.icproj *.csproj *.rc *.def 66 | Web=*.htm *.html *.shtml *.stm *.xhtml *.xht *.css *.js *.javascript *.es *.jsp *.asp *.asa 67 | X11=XF86* .X* *.ad 68 | XML=*.xml *.dtd 69 | Xquery=*.xq *.xql *.xqm *.xquery *.xqy 70 | Xsd=*.xsd 71 | Xslt=*.xsl *.xslt 72 | Yacc=*.y *.yy 73 | Yaml=*.yaml *.yml 74 | 75 | -------------------------------------------------------------------------------- /doc/EasyGrep.txt: -------------------------------------------------------------------------------- 1 | *EasyGrep.txt* 2 | ============================================================================== 3 | EasyGrep *EasyGrep* 4 | ============================================================================== 5 | 6 | Author: Dan Price vim@danprice.fastmail.net *EasyGrep_Author* 7 | 8 | Goal: To be an easy to use, powerful find and |EasyGrep_Motivation| 9 | replace tool for users of all skill levels. 10 | Version: 1.1 |EasyGrep_History| 11 | 12 | License: Public domain, no restrictions whatsoever |EasyGrep_License| 13 | Contribute: Please report any bugs or suggestions |EasyGrep_Bugs| 14 | to the address above. |EasyGrep_Future| 15 | 16 | 17 | ============================================================================== 18 | Table of Contents *EasyGrep_Contents* 19 | ============================================================================== 20 | 21 | 22 | 1. Motivation.................|EasyGrep_Motivation| 23 | 2. Operation..................|EasyGrep_Operation| 24 | 2.1 Modes..................|EasyGrep_OperationModes| 25 | 2.2 Performance............|EasyGrep_Performance| 26 | 3. Keymaps....................|EasyGrep_Keymaps| 27 | 3.1 Default Bindings ......|EasyGrep_KeymapsDefault| 28 | 3.2 Option Mappings........|EasyGrep_KeymapsOptions| 29 | 3.3 Mapping Customization..|EasyGrep_KeymapsCustomization| 30 | 4. Commands...................|EasyGrep_Commands| 31 | 5. Options....................|EasyGrep_Options| 32 | 5.1 Summary................|EasyGrep_OptionsSummary| 33 | 5.2 Explorer...............|EasyGrep_OptionsExplorer| 34 | 5.3 Details................|EasyGrep_OptionsDetail| 35 | 6. Bugs.......................|EasyGrep_Bugs| 36 | 7. Future.....................|EasyGrep_Future| 37 | 8. History....................|EasyGrep_History| 38 | 9. License....................|EasyGrep_License| 39 | 40 | 41 | ============================================================================== 42 | 1. Motivation *EasyGrep_Motivation* 43 | ============================================================================== 44 | 45 | EasyGrep's main goal is to make search and replace in files easy. Other Vim 46 | plugins provide similar functionality, but few provide the same level of 47 | functionality with as little configuration as EasyGrep does. In the common 48 | case, all it takes to search for a string across multiple files is three 49 | keypresses: vv. No clicks, no commands, no project/tags setup -- just 50 | three keys. When you need a substitution, it also takes the same number of 51 | keys to start a replace in files. After using EasyGrep, you'll wonder at how 52 | you got around without it. 53 | 54 | While EasyGrep's default configuration will satisfy many users, it provides 55 | more than a dozen options for those who need more control |EasyGrep_Options|. 56 | When you need to change options, EasyGrep provides an options explorer that 57 | indicates which files will be searched and allows visual customization of its 58 | options |EasyGrep_OptionsExplorer|. When this isn't fast enough, EasyGrep 59 | provides key mappings for each option to toggle its value 60 | |EasyGrep_KeymapsOptions|. If you can't find an option you need, contact me 61 | |EasyGrep_Author| and if it doesn't already exist, we'll make it happen. 62 | 63 | I hope that EasyGrep makes Vim more fun, productive, and easy for you to use. 64 | 65 | Happy Vimming! 66 | 67 | 68 | ============================================================================== 69 | 2. Operation *EasyGrep_Operation* 70 | ============================================================================== 71 | 72 | EasyGrep makes using Vim's grep capabilities easier. When using EasyGrep, 73 | searching for a word in multiple files is as easy as typing a simple mapping 74 | (see |EasyGrep_Keymaps)|. In addition to keymaps, search and replace can be 75 | invoked through commands (see |EasyGrep_Commands)|. 76 | 77 | To determine which files to search, EasyGrep provides several builtinmodes, 78 | described in the next section. 79 | 80 | ------------------------------------------------------------------------------ 81 | 2.1 Search Modes *EasyGrep_OperationModes* 82 | ------------------------------------------------------------------------------ 83 | 84 | All 85 | All files will be searched (default). 86 | 87 | Buffers 88 | Files currently open in vim will be searched. Recursion has no meaning in 89 | this mode, and will be turned off. 90 | 91 | TrackExt 92 | Files that match the extension of the currently opened file will be 93 | searched. Additionally, this extension can be mapped to a user defined 94 | set of extensions that will also be searched |EasyGrepFileAssociations|. 95 | 96 | For example: in the default configuration, when test.cpp is open, files 97 | that match any one of 98 | 99 | *.cpp *.hpp *.cxx *.hxx *.cc *.c *.h 100 | 101 | will be searched when a Grep is initiated. I find this mode to be the 102 | most useful. 103 | 104 | User 105 | Specify a custom set of file extensions to search. 106 | 107 | 108 | The startup mode is indicated by |EasyGrepMode|. These modes can be quickly 109 | changed through the |EasyGrep_OptionsExplorer| or |EasyGrep_KeymapsOptions|. 110 | 111 | 112 | ------------------------------------------------------------------------------ 113 | 2.2 Performance *EasyGrep_Performance* 114 | ------------------------------------------------------------------------------ 115 | 116 | By default, EasyGrep completes its searches using Vim's vimgrep command. While 117 | easy to use, vimgrep's searching time can be considerably longer than 118 | traditional tools like your system's grep command. Because of this, EasyGrep 119 | provides several options to allow you to control your performance: 120 | 121 | - Consider setting EasyGrep to use your system's grep command. 122 | (see |EasyGrepCommand|) 123 | - Consider whether recursive operation is set and whether you need it on all 124 | the time. Note that it can be toggled easily with 'vyr'. 125 | (see |EasyGrepRecursive|) 126 | - Consider setting grep exclusions if your grep command supports it. 127 | (see |EasyGrepFilesToExclude|) 128 | 129 | 130 | ============================================================================== 131 | 3. Keymaps *EasyGrep_Keymaps* 132 | ============================================================================== 133 | 134 | This section discusses EasyGrep's default keybindings and how to customize 135 | them. 136 | 137 | ------------------------------------------------------------------------------ 138 | 3.1 Default Bindings *EasyGrep_KeymapsDefault* 139 | ------------------------------------------------------------------------------ 140 | 141 | EasyGrep uses Vim's leader key, which is by default '\'. For information on 142 | this key, type ":help mapleader". 143 | 144 | vv - Grep for the word under the cursor, match all occurences, 145 | like 'g*'. See ":help gstar". 146 | vV - Grep for the word under the cursor, match whole word, like 147 | '*'. See ":help star". 148 | va - Like vv, but add to existing list. 149 | vA - Like vV, but add to existing list. 150 | 151 | vr - Perform a global search on the word under the cursor 152 | and prompt for a pattern with which to replace it. 153 | vR - Like vr, but match whole word. 154 | 155 | Each of these commands has an 'all occurences' and 'whole word' option, 156 | designated by the case of the last character. If you would prefer that these 157 | be reversed, see |EasyGrepInvertWholeWord|. 158 | 159 | In addition to grepping the word under the cursor, text may be visually 160 | selected and these mappings may be used analogously to as they are used above. 161 | Visual selections will automatically be escaped so as not to confuse the 162 | selection with a regular expression. 163 | 164 | e.g. Selecting the text inside the quotes here "/" will match 165 | against "\" but not against "word". 166 | 167 | To search with a regular expression, see the :Grep command |EasyGrep_Commands| 168 | 169 | Each of the above commands will search files according to settings 170 | controlled by: 171 | 172 | vo - Open an options explorer to select the files to search in and 173 | set grep options. 174 | 175 | For the options provided, see |EasyGrep_Options|. 176 | 177 | 178 | ------------------------------------------------------------------------------ 179 | 3.2 Option Mappings *EasyGrep_KeymapsOptions* 180 | ------------------------------------------------------------------------------ 181 | 182 | For each of the options presented in the options explorer, there is a mapping 183 | that allows a direct change of this option. The mapping for option is 184 | vy