问题
I've got a weird problem where if i do something like this in a gnu screen window, that window starts responding in weird ways
ls *.cpp | xargs vim
After I exit from vim, the screen window doesn't echo any command. It even does not echo CR.
Any suggestions?
回答1:
Piping changes vim's stdin and causes problems. Try this instead (for bash, zsh, etc.):
vim $(find . -name "*.cpp")
回答2:
How about vim *.cpp
?
Maybe for file in *.cpp; do vim "$file"; done
could work too. Edit each file and exit.
Or start vim
and add all cpp
files with following command: :argadd *.cpp
回答3:
When using Vim in a pipe like this, you'll probably notice the following warning:
Vim: Warning: Input is not from a terminal
That's Vim telling you that it cannot function as it's supposed to be (i.e. in interactive mode; you can still use it in "batch mode" by feeding it Ex commands to process). That explains the weirdness you experience after Vim quits.
来源:https://stackoverflow.com/questions/11187744/using-xargs-vim-with-gnu-screen