Skip to main content
added 696 characters in body
Source Link
msam
  • 113
  • 5

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.

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.

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.

Source Link
msam
  • 113
  • 5

Pipe file list to vim and browser them like a folder

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.