3

I started using vim two weeks ago switching from sublime and I am a ruby developer I know for a fact that Ack and Ag work very good on a Mac while they're not optimized for my Ubuntu machine.

These are the steps I usually follow when I want to search for words in my project folder (methods, variables, whatever) using "git grep" to search in all of the files in my project folder that contains those words, but it feels a very slow to me to:

1) Copy the words I want to search, from one file opened in vim
2) Ctrl + Z to send vim in background and use the console
3) git grep 'what I want to search' to actually perform the global search
4) Copy the file path from the list of results
5) fg to resume vim from background
6) :e filepath in vim

What do you use in your environments?
And what is your opinion about this topic?

  • 1
    Can you be more specific on what you want to do? – ramonovski May 30 '13 at 21:03
  • I just edited the description. Is it clear? – Barbared May 30 '13 at 21:18
1

You might want to have a look at fugitive: https://github.com/tpope/vim-fugitive . You could use the :Ggrep string command, what would merge steps 2, 3 and 5 of your example.

See this link for more details on :Ggrep: http://vimcasts.org/episodes/fugitive-vim-exploring-the-history-of-a-git-repository/

1

Here are some alternatives you might want to check:

  1. ack-grep

  2. greplace.vim

  3. grep.vim

I use the built-in :vimgrep command, it just works for me. For external tools I prefer ack though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.