4 ms·
Vim command has a ‘-‘ argument which instructs it to read from standard input. Here’s an example of interactively selecting files to delete in the current direc
by k3vinw 3y ago
Vim command has a ‘-‘ argument which instructs it to read from standard input. Here’s an example of interactively selecting files to delete in the current directory: find . -type f -name *.txt | vim - | xargs rm
- Hello71 3y agowith seq 1 10 | vim - | cat > x, I get "Vim: Warning: Output is not to a terminal" and the pipeline appears to hang, but actually the output is going to "x". In other words, your command deletes some unknown files depending on your terminal setup.
- k3vinw 3y agoOof. Should have tried this one first before posting. The tricky part of this is that reading from standard input implies non-interactive mode. Not as succinct but you can still pipe your output to vim, make your edits, run :w vimpipe to save your edits, and pipe the output of your vimpipe file to another command. find . -type f -name \.txt | vim -; cat vimpipe | xargs rm
- k3vinw 3y agoThere’s also an existing command line utility for this called vipe which I’ve always wanted to try, but never got around too. It’s part of moreutils: https://joeyh.name/code/moreutils/ https://joeyh.name/code/moreutils/