Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions plugin/grep.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down