4 ms·
fzf looks awesome, thanks for sharing. Didn't know about it. Do you have an example on how you can do this with vim?
by chfritz 3y ago
fzf looks awesome, thanks for sharing. Didn't know about it. Do you have an example on how you can do this with vim?
- MobiusHorizons 3y agoI used it in a shell script with a temp file. You could pretty easily write a shell script for this behavior though to be used in a pipeline #!/bin/sh TEMP=“$(mktmp)” cat > “$TEMP” $EDITOR “$TEMP” cat “$TEMP”
- k3vinw 3y agoVim 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/