Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
scrooloose
/
grep_menuitem.vim
Created
Oct 9, 2009
Star
4
Fork
4
Star
Code
Revisions
4
Stars
4
Forks
4
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
nerdtree plugin to integrate nerdtree with :grep
Raw
grep_menuitem.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
if
exists
(
"
g:loaded_nerdtree_grep_menuitem
"
)
finish
endif
let
g:
loaded_nerdtree_grep_menuitem
=
1
if
!
executable
(
"
grep
"
)
finish
endif
call
NERDTreeAddMenuItem
({
\
'
text
'
:
'
(g)rep directory
'
,
\
'
shortcut
'
:
'
g
'
,
\
'
callback
'
:
'
NERDTreeGrepMenuItem
'
})
function
!
NERDTreeGrepMenuItem
()
let
n
=
g:
NERDTreeDirNode
.
GetSelected
()
let
pattern
=
input
(
"
Search Pattern:
"
)
if
pattern
==
'
'
return
endif
"
use the previous window to jump to the first search result
wincmd
w
let
old_shellpipe
=
&
shellpipe
try
"
a hack for *nix to ensure the grep output isnt echoed in vim
let
&
shellpipe
=
'
&>
'
exec
'
silent grep -r
'
. pattern .
'
'
.
n
.
path
.
str
()
finally
let
&
shellpipe
=
old_shellpipe
endtry
let
hits
=
len
(
getqflist
())
if
hits
==
0
redraw
echo
"
No hits
"
elseif
hits
>
1
copen
wincmd
p
endif
endfunction
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.