Wikia

Vim Tips Wiki

Changes: Use glimpse from within Vim

Edit

Back to page

(add category)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 3: Line 3:
 
|previous=1020
 
|previous=1020
 
|next=1023
 
|next=1023
|created=October 18, 2005
+
|created=2005
 
|complexity=basic
 
|complexity=basic
 
|author=Jean-Rene David
 
|author=Jean-Rene David
Line 35: Line 35:
   
 
==Comments==
 
==Comments==
I'm using this to use <tt>:Glimpse</tt> in parallel with <tt>:grep</tt>
+
I'm using this to use <code>:Glimpse</code> in parallel with <code>:grep</code>
   
 
<pre>
 
<pre>

Latest revision as of 06:04, July 13, 2012

Tip 1021 Printable Monobook Previous Next

created 2005 · complexity basic · author Jean-Rene David · version 6.0


To use glimpse to search your files instead of grep -r, you can use these mappings:

set grepformat+=%f:\ %l:%m
set grepprg=glimpse\ -nyH\ $HOME/indexdir\ $*
nnoremap <silent> \g :grep <cword><CR>:cwindow<CR>
nnoremap <silent> \G :!glimpseindex -F -H $HOME/indexdir -b ${PWD}<CR>

You must:

1. Have glimpse installed on your system. (see webglimpse.net).

2. Precompile an index with glimpseindex. The mapping above lets glimpseindex decide which files to scan and puts the index in $HOME/indexdir. You can change that if you like.

3. Grep away using the mapping above or, alternatively:

:grep pattern

Searches are blinding fast with even large projects. By using the grepprg option, you get the benefit of using the quickfix window to browse through your search results.

CommentsEdit

I'm using this to use :Glimpse in parallel with :grep

set gfm+=%f:\ %l:\ %m
com -nargs=* Glimpse let s:oldgrep = &grepprg | set grepprg=glimpse | grep <args> | let &grepprg = s:oldgrep

Around Wikia's network

Random Wiki