3

One can configure Vim to use temporary files(stored in /tmp directory by default) when shell commands(for example :%!ls) are executed. Those temporary files contain the output of an external command. With set noshelltemp pipes are used instead. However, why is it necessary for Vim to use temporary file or pipe for shell commands in the first place?

6

How else do you expect Vim to retrieve the output of the commands?

Your :%!ls writes the contents of the buffer to ls's stdin, reads the stdout from ls, and replaces the contents of the buffer with that data from stdout (see :help filter). In order to do that, Vim needs to be able to read the output, so it uses a pipe or temp file depending on how you have 'shelltemp' set.

If all you want to do is run a command without feeding the data back into Vim, then that's a different matter1. Then Vim can just run the command and let the terminal show you the output, with no intermediate files or pipes.

1: Well, it's a different matter if you're running in the terminal. If you're running gvim, then it has to do the same thing so the output of the command can be displayed in gvim's window.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.