0

In particular, I'm editing files in Verilog and would like to see other instances of a word under the cursor in other files. Ideally, it'd bring up a list like the auto-complete list. I can then select the line entry and vim would open the file (either in the same window or a new tab).

I've seen this feature in Emacs. I have to think it exists in Vim somewhere.

Qiu
  • 5,651
  • 10
  • 49
  • 56
jkang
  • 483
  • 7
  • 19

3 Answers3

1

This would be really fun to write in vimscript, but I don't exactly have time at the moment. Hopefully this will get you going in the right direction:

There is a vim plugin called Fugitive

It allows you to do things like git grep, or git blame right from you vim console. https://github.com/tpope/vim-fugitive

Their git grep command, Ggrep, should get you a list of local files with whatever word you want to grep for. Possibly check out this Q/A for getting it to work nicely: Getting 'git grep' to work effectively in vim

Last thing I would do is write a little vimscript function and a keystroke alias that would call Ggrep with the word under the cursor.

(hopefully I'll have time to write a better answer later)

Community
  • 1
  • 1
BananaNeil
  • 10,322
  • 7
  • 46
  • 66
1

If you have a tags file available, you might be able to use :tselect identifier for that purpose.

Vitor
  • 1,936
  • 12
  • 20
0

Vimgrep is your friend.

:vimgrep /pattern/ <path>/**

This will add lines to the quickfix window. Each line is the text from the line in a file that matches the pattern. The ** is shorthand for recurse into subdirectories.

sashang
  • 11,704
  • 6
  • 44
  • 58