On , I learnt ...
How to pipe an argument list into Vim
Use something like:
echo file1 file2 | xargs -o vim
The -o
option for xargs
re-opens stdin
as /dev/tty
(rather than the
default /dev/null
) and is essential otherwise Vim will break your terminal
when it exits.
This is a useful way of populating Vim’s argument list. It works especially
well with modern search tools fd
and ripgrep
. For example:
$ rg --type py --files-with-matches "logger = .*getLogger*" \
| xargs rg --files-without-match "logger\." \
| xargs -o vim
This instructs Vim to open all Python files that create a logger
instance but
don’t actually use it.