Opening files in vim from output of command

Many command line tools can output a list of files, this is quite powerful. I often want to search for something, then open it from a fuzzy picker. This can be done with fzf in the terminal, but often I am already in vim and I want to open it inside m…

Many command line tools can output a list of files, this is quite powerful. I often want to search for something, then open it from a fuzzy picker. This can be done with fzf in the terminal, but often I am already in vim and I want to open it inside my current session.



Telescope

how to pass a custom command to telescope

Telescope is the fuzzy file finder I use every day inside of neovim. Its pretty fantastic and easy to extent like this. This first example I am only passing in files from the current working directory by using ls.

:Telescope find_files find_command=ls

This brings up a normal Telescope picker with results from the ls command.



More arguments

how to pass a muli-argument command to telescope

Adding more arguments can be done by comma separating them as shown in the example below. This command will run the silver-searcher, search for all occurrences of nvim inside of a markdown file, and return only the file paths so Telescope can pick from them.

:Telescope find_files find_command=ag,nvim,--md,-l

Print Share Comment Cite Upload Translate
APA
Waylon Walker | Sciencx (2024-03-29T01:12:50+00:00) » Opening files in vim from output of command. Retrieved from https://www.scien.cx/2021/12/28/opening-files-in-vim-from-output-of-command/.
MLA
" » Opening files in vim from output of command." Waylon Walker | Sciencx - Tuesday December 28, 2021, https://www.scien.cx/2021/12/28/opening-files-in-vim-from-output-of-command/
HARVARD
Waylon Walker | Sciencx Tuesday December 28, 2021 » Opening files in vim from output of command., viewed 2024-03-29T01:12:50+00:00,<https://www.scien.cx/2021/12/28/opening-files-in-vim-from-output-of-command/>
VANCOUVER
Waylon Walker | Sciencx - » Opening files in vim from output of command. [Internet]. [Accessed 2024-03-29T01:12:50+00:00]. Available from: https://www.scien.cx/2021/12/28/opening-files-in-vim-from-output-of-command/
CHICAGO
" » Opening files in vim from output of command." Waylon Walker | Sciencx - Accessed 2024-03-29T01:12:50+00:00. https://www.scien.cx/2021/12/28/opening-files-in-vim-from-output-of-command/
IEEE
" » Opening files in vim from output of command." Waylon Walker | Sciencx [Online]. Available: https://www.scien.cx/2021/12/28/opening-files-in-vim-from-output-of-command/. [Accessed: 2024-03-29T01:12:50+00:00]
rf:citation
» Opening files in vim from output of command | Waylon Walker | Sciencx | https://www.scien.cx/2021/12/28/opening-files-in-vim-from-output-of-command/ | 2024-03-29T01:12:50+00:00
https://github.com/addpipe/simple-recorderjs-demo