5

Is there a way in vim to search (grep/ack etc..) for strings in files in a similar fashion like one would do in CommandT?

So say that I invoke the search window. Possible matches for the string I wrote so far will start to show while I continue typing.

tUrG0n
  • 4,178
  • 3
  • 20
  • 26

2 Answers2

4

I don't think there is any native (as in :set findasyoutype) way to do exactly what you want.

But there's a plugin for that ! Well, at least three:

  • LustyExplorer provides this feature through its :LustyBufferGrep command. It requires Vim to be compiled with Ruby support.
  • CtrlP too, provides this feature through the line extension.
  • You can also try FuzzyFinder which I've never used.
romainl
  • 186,200
  • 21
  • 280
  • 313
  • Out of curiosity, what is the reason for the downvote? Not enough details? Proposing to use a plugin instead of a native feature? – romainl Mar 16 '12 at 14:18
  • I am not the downvoter, but as far as I can tell you can't search in multiple files with FuzzyFinder. Or I have not found how. You can use fuzzy search in a single file, or to open a file in your path, but not to find text in multiple files. – Xavier T. Mar 16 '12 at 15:16
  • Well yes, as I wrote I've never used FuzzyFinder so I have no idea if/how it does that but LustyExplorer searches through all available buffers. CtrlP is limited to the current buffer. – romainl Mar 16 '12 at 15:32
  • Lusty and CtrlP provide this for opened buffers and not uopened ones. However CtrlP seems very interesting with its extension capability!! will def look into it! (Btw.. i upvoted :) ) – tUrG0n Mar 16 '12 at 16:38
  • there is also https://github.com/mileszs/ack.vim that provides this functionality, but it is not very interactive. – tUrG0n Mar 16 '12 at 16:53
  • There are many ways (native or enhanced) to search the content of files on your system in Vim. The native `:Grep` or `:VimGrep` coupled with the quickfix window would be the 1st choices, `ack.vim` is great too and there are [many other plugins](http://www.vim.org/scripts/script.php?script_id=2438) that try to make that task easier. This part of your question is very easy. But you want a fuzzy search interface and AFAIK, the only ones that add fuzzy matching to regular searching are the ones in my answer. – romainl Mar 16 '12 at 17:12
1

I don't know how it looks like in CommandT, but if you issue the command :set incsearch (or put it in your .vimrc), once you search as usual, using /, vim highlights the first found item.

nietaki
  • 8,758
  • 2
  • 45
  • 56