Recently I was watching the following YouTube video https://youtu.be/fP_ckZ30gbs?t=1365 and got confused at the part where he is talking about opening multiple files at once. I tried this on my own with the following files in my working directory.

Don't watch the clock; do what it does. Keep going.
-- Sam Levenson

When the going gets tough, the tough get going.
-- Billy Ocean

If you don't know where you are going,
you might wind up someplace else.
-- Yogi Berra

I first navigated to the directory containing these files. I then opened up vim and ran the :Rg going command to search for all instances of going in the pwd. It showed the above three files which I then selected with Shift + Tab. (Tab also seems to work for me.)

Selection of 3 files

After the pink '>' shows that all three files are selected, I try to open them all up at once in a horizontal split via Ctrl + x.

After Ctrl + x

However, only the current selection 'tough.txt' shows up, the current selection being whichever file the bright red arrow is pointing at. The quickfix list has been populated with the three files, but they do not show up in horizontal split windows. 

I do have fzf.vim installed and I placed this code at the bottom of my .vimrc:

" Enable FZF to search for strings within hidden files
command! -bang -nargs=* Rg
  \ call fzf#vim#grep(
  \   'rg --hidden --column --line-number --no-heading --color=always --smart-case -- '.shellescape(<q-args>), 1,
  \   fzf#vim#with_preview(), <bang>0)

As far as I can tell, the Rg command has not been customized to suppress the opening of multiple files at once.   Any idea why I can't open multiple files with an Rg command?

1 Answer 1


Any idea why I can't open multiple files with an Rg command?

That is how Rg is implemented. If there are multiple entries selected it opens all of them in vim quickfix.

Check ag_handler it uses for that: https://github.com/junegunn/fzf.vim/blob/0eb385065bf614abb6f38db85f0a09eddec728fc/autoload/fzf/vim.vim#L722

You can rewrite fzf#vim#grep function https://github.com/junegunn/fzf.vim/blob/0eb385065bf614abb6f38db85f0a09eddec728fc/autoload/fzf/vim.vim#L768

to use your own sink handler which would open the files in split.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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