Getting 'git grep' to work effectively in vim

后端 未结 3 1879
借酒劲吻你
借酒劲吻你 2021-01-11 10:09

Fugitive.vim allows me to run git grep commands; unfortunately, the results are not stored in a quickfix-list, so I need to run :cw after a :

相关标签:
3条回答
  • 2021-01-11 10:51

    This works for me:

    :command -nargs=+ Ggr execute 'silent Ggrep!' <q-args> | cw | redraw!
    
    0 讨论(0)
  • 2021-01-11 10:51

    Already mentioned in one of the comments, but I thought the plugin-recommended solution on the fugitive.vim site deserved its own answer:

    autocmd QuickFixCmdPost *grep* cwindow
    

    (from: https://github.com/tpope/vim-fugitive)

    0 讨论(0)
  • 2021-01-11 10:54

    You can use the <args> symbol to insert the arguments given to your custom command:

    :command -nargs=+ Ggr execute 'Ggrep' <q-args> | cw
    

    Note: As the :Ggrep command doesn't have the -bar argument, it cannot be chained, so :execute has to be used.

    0 讨论(0)
提交回复
热议问题