vim

Opening files in vim from output of command

waylonwalker

Waylon Walker

Posted on December 28, 2021

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 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
waylonwalker
Waylon Walker

Posted on December 28, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Baby Steps with Rust
programming Baby Steps with Rust

November 29, 2024

OOP Bootcamp 2: The Why of OOP
oop OOP Bootcamp 2: The Why of OOP

November 29, 2024

The Story of Nel
satire The Story of Nel

November 29, 2024