Is it possible to pipe list of files e.g. from grep and have this file list opened in vim file manager in similar fashion like when you open a folder with vim?
Note that I do not want to just write the file names into vim buffer like a text. I want vim to treat them as if these files were in a folder and I would be able to choose which one to open.
EDIT: Thanks to your great advice I could add these two functions in my .bashrc, they do almost exactly what I want:
# Find files by name in the notes and open them as subset in vim, opens first file in the search in the buffer:
function notefv {
vim --cmd 'set efm=%f' -c copen -q <(find ~/Notes -name "*$1*")
}
# Grep notes for a keyword, open the result in vim quickfix list, opens first file in the search in the buffer
function noteg {
vim --cmd 'set efm=%f' -c copen -q <(grep -irl --color $1 ~/Notes/*)
}
This uses native vim functionality. if I'll have nothing to do, I'll try to rewrite it so that the subset of files is opened in dervish or NerdTree.
vim --cmd 'set efm=%f' -c copen -q <(find . -type f)
. See:help -q
in Vim to see how to populate the quickfix list when invoking Vim. Withgrep
it might be even easier, since Vim might be expecting that kind of format for the quickfix list..xargs
, e.g.ls | xargs vim -o -- # open all files in split
. I would suggest to add th--
, because otherwise you might run into issues if you had files starting with a-
;)gf
command?