Vim Tips Wiki

Changes: Use glimpse from within Vim


Back to page

(add category)
(Change <tt> to <code>, perhaps also minor tweak.)
Line 3: Line 3:
|created=October 18, 2005
|author=Jean-Rene David
|author=Jean-Rene David
Line 35: Line 35:
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>

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

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.


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