Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast 'Find in Files' for VIM?

What are some options for getting really fast 'Find in Files' searching in VIM?

Our codebase is large enough that searching needs to work off an index. grep/vimgrep/etc are too slow.

Indexing doesn't need to be particularly fast; I can index overnight.

Thanks,

[EDIT] I'm also working in a Windows environment.

like image 567
Christopher Stott Avatar asked Jul 07 '09 23:07

Christopher Stott


People also ask

How do I navigate multiple files in vim?

Ctrl-W w to switch between open windows, and Ctrl-W h (or j or k or l ) to navigate through open windows. Ctrl-W c to close the current window, and Ctrl-W o to close all windows except the current one. Starting vim with a -o or -O flag opens each file in its own split.

How do we use grep to search for a pattern in multiple files in vim?

From the root of your project, you can search through all your files recursively from the current directory like so: grep -R '. ad' . The -R flag is telling grep to search recursively.

Can you grep in Vim?

Vim provides these commands for searching files: :grep.


2 Answers

If it's source code (rather than full text search), then ctags with the TagList plugin should work well for your needs. See, for example:

http://www.thegeekstuff.com/2009/04/ctags-taglist-vi-vim-editor-as-sourece-code-browser/

EDIT: TagList and ctags will work on Windows as well (that's what I use). See the TagList install page and FAQ. The following links might prove useful:

  • http://www.vim.org/scripts/script.php?script_id=273
  • http://vim-taglist.sourceforge.net/installation.html
  • http://vim-taglist.sourceforge.net/faq.html

There's also a TagList forum where you can get further help:

http://tech.groups.yahoo.com/group/taglist/

I set it up on my windows machine a while back, but I don't remember encountering any problems.

like image 71
ars Avatar answered Oct 24 '22 08:10

ars


Something that I use, but not through vim, is ack: http://betterthangrep.com/

It is a perl based tool, and it should be usable in Windows.

like image 25
phss Avatar answered Oct 24 '22 07:10

phss