diff --git a/plugin/grep.vim b/plugin/grep.vim index 6a88895..ae50fdb 100644 --- a/plugin/grep.vim +++ b/plugin/grep.vim @@ -233,12 +233,16 @@ " " :let Grep_Skip_Dirs = 'dir1 dir2 dir3' " +" NOTE: Grep_Skip_Dirs only works in R[xx]grep command set. +" " The 'Grep_Skip_Files' variable specifies the list of files to skip while " doing recursive searches. By default, this is set to '*~ *,v s.*'. You can " change this using the let command: " " :let Grep_Skip_Files = '*.bak *~' " +" NOTE: Grep_Skip_Files only works in R[xx]grep command set. +" " By default, when you invoke the Grep commands the quickfix window will be " opened with the grep output. You can disable opening the quickfix window, " by setting the 'Grep_OpenQuickfixWindow' variable to zero: @@ -500,8 +504,7 @@ function! s:RunGrepRecursive(cmd_name, grep_cmd, action, ...) if a:{argcnt} =~ '^-' let grep_opt = grep_opt . " " . a:{argcnt} elseif pattern == "" - let pattern = g:Grep_Shell_Quote_Char . a:{argcnt} . - \ g:Grep_Shell_Quote_Char + let pattern = a:{argcnt} else if filepattern != "" let filepattern = filepattern . " " . a:{argcnt} @@ -543,11 +546,12 @@ function! s:RunGrepRecursive(cmd_name, grep_cmd, action, ...) if pattern == "" return endif - let pattern = g:Grep_Shell_Quote_Char . pattern . - \ g:Grep_Shell_Quote_Char echo "\r" endif + let highlightpattern = pattern + let pattern = g:Grep_Shell_Quote_Char . pattern . g:Grep_Shell_Quote_Char + let cwd = getcwd() if g:Grep_Cygwin_Find == 1 let cwd = substitute(cwd, "\\", "/", "g") @@ -637,6 +641,11 @@ function! s:RunGrepRecursive(cmd_name, grep_cmd, action, ...) endif call s:RunGrepCmd(cmd, pattern, a:action) + + " search the pattern in the buffers so that it can be highlight + let @/ = highlightpattern + " highlight the pattern in the quickfix window + execute 'match MatchParen ' . '/' . highlightpattern . '/' endfunction " RunGrepSpecial() @@ -734,6 +743,7 @@ function! s:RunGrepSpecial(cmd_name, which, action, ...) echo "\r" endif + let highlightpattern = pattern let pattern = g:Grep_Shell_Quote_Char . pattern . g:Grep_Shell_Quote_Char " Add /dev/null to the list of filenames, so that grep print the @@ -743,6 +753,11 @@ function! s:RunGrepSpecial(cmd_name, which, action, ...) let cmd = cmd . pattern . " " . filenames call s:RunGrepCmd(cmd, pattern, a:action) + + " search the pattern in the buffers so that it can be highlight + let @/ = highlightpattern + " highlight the pattern in the quickfix window + execute 'match MatchParen ' . '/' . highlightpattern . '/' endfunction " RunGrep() @@ -767,8 +782,7 @@ function! s:RunGrep(cmd_name, grep_cmd, action, ...) if a:{argcnt} =~ '^-' let grep_opt = grep_opt . " " . a:{argcnt} elseif pattern == "" - let pattern = g:Grep_Shell_Quote_Char . a:{argcnt} . - \ g:Grep_Shell_Quote_Char + let pattern = a:{argcnt} else let filenames= filenames . " " . a:{argcnt} endif @@ -807,11 +821,12 @@ function! s:RunGrep(cmd_name, grep_cmd, action, ...) if pattern == "" return endif - let pattern = g:Grep_Shell_Quote_Char . pattern . - \ g:Grep_Shell_Quote_Char echo "\r" endif + let highlightpattern = pattern + let pattern = g:Grep_Shell_Quote_Char . pattern . g:Grep_Shell_Quote_Char + if filenames == "" if v:version >= 700 let filenames = input("Search in files: ", g:Grep_Default_Filelist, @@ -833,6 +848,11 @@ function! s:RunGrep(cmd_name, grep_cmd, action, ...) let cmd = cmd . " " . filenames call s:RunGrepCmd(cmd, pattern, a:action) + + " search the pattern in the buffers so that it can be highlight + let @/ = highlightpattern + " highlight the pattern in the quickfix window + execute 'match MatchParen ' . '/' . highlightpattern . '/' endfunction " Define the set of grep commands