1

I want to :Ggrep not from the git root directory but only in the directory the current file is open in vim.

I tried :Ggrep search_key ., but it still looks from the git root.

Even :Git grep search_key . does the same as :Ggrep

prat0318
  • 571
  • 1
  • 8
  • 19

1 Answers1

1

. would expand to the current working directory iirc. Instead you should do something like this :

:Ggrep search_key <C-R>=expand('%:h')<CR><CR>
Dhruva Sagar
  • 7,089
  • 1
  • 25
  • 34
  • This is almost right, but it appears that `:Ggrep` treats relative directories as relative to the repository root, so you need to use the absolute directory with `expand('%:p:h')`. – Cartroo Aug 27 '14 at 08:26
  • It is relative the the current directory within vim. – Dhruva Sagar Aug 28 '14 at 10:49
  • No, I don't believe so. From [fugitive.vim:1206](https://github.com/tpope/vim-fugitive/blob/90ee6fb5d255d14d9f12f2469f92ee50149f5b44/plugin/fugitive.vim#L1206) it looks to me that it's always relative to the repository root. – Cartroo Aug 29 '14 at 10:45