I've sometimes tried invoking Vim using xargs
, like this:
find . -name '*.java' | xargs vim
… which kind of works:
As Vim launches, I see the following warning flash briefly:
Vim: Warning: Input is not from a terminal
- Editing works —
:files
correctly enumerates all of the.java
files as expected. - I can save and quit.
However, after exiting Vim, my terminal is borked:
- Whatever I type at the shell prompt is not echoed.
- Carriage returns don't appear at all, and line feeds only sometimes appear.
This goes on until I issue a reset(1)
command to reinitialize the terminal.
Is this a Vim bug, or is there a more satisfactory explanation for why it interacts with the terminal like that? I've seen it happen on Vim up to version 7.3 (the version doesn't seem to matter) on Linux and various Unices.
I'm aware of one workaround, namely vim $(find . -name '*.java')
. Other workarounds would be welcome, though that's not my main question.
xargs
uses a dummystdin
that can't be used by Vim and breaks everything afterwards.