1

I am using Gvim with Ag.vim plugin for search. I am trying to use options for --before 4 and --after 4 to get the context of the code. It returns the results in quickfix window as a single line. How to show the before and after code for a search pattern?

Here is my search pattern and path.

:Ag -i --after 4 --before 4 pattern /search/path/

Is there a way to show the results in buffer or a tab rather than quickfix window?

I added this in my vimrc but it still shows the results in quickfix window.

let g:ag_lhandler="topleft lopen"

Thanks.

NotepadPlusPlus PRO
  • 987
  • 1
  • 8
  • 21
  • You can use a redir command. First `:redir a`, then perform your operations and then type `:redir END`. Now the content will be in register a. You can create a new buffer by typing `:bnew filename` and then get into insert mode and then press Ctrl and R , and then press `a`. Your content will be pasted. If you want a function/command for this, I will do :) – SibiCoder Jun 30 '16 at 15:14
  • Thanks @SibiCoder. There are too many steps for such functionality. Shouldn't Ag's options work as indented in Vim plugin? – NotepadPlusPlus PRO Jun 30 '16 at 15:37
  • 1
    You can use the plugin's issue tracker https://github.com/rking/ag.vim . Once you find the solution you can add as an answer. (I can create a function or command for your execpted workflow but dont know `Ag`.) – SibiCoder Jun 30 '16 at 16:34
  • 3
    Use the [CtrlSF](https://github.com/dyng/ctrlsf.vim) plugin instead of Ag. – Sato Katsura Jun 30 '16 at 16:45
  • @SatoKatsura Just came across `CtrlSF` plugin. It does all that I requested here. Thanks a lot. – NotepadPlusPlus PRO Jun 30 '16 at 16:57

1 Answers1

0

All the requirements of my question can be fulfilled by a Vim plugin called CtrlSF (CtrlSF Vim Plugin) Thanks to @SatoKatsura for the recommendation.

NotepadPlusPlus PRO
  • 987
  • 1
  • 8
  • 21