Is it legal to do :r!vi in vi?

A friend asked me to try it and it jammed my terminal. What exactly causes this? Is there anyway to recover the terminal without closing it and opening a new one?

  • 3
    It jams your terminal.
    – user859
    Feb 21 '17 at 16:22
  • 5
    I think this question would be more on topic/high-quality if you edit it to be more about the practical side. For example "What causes my terminal to freeze when I do this command" and "(How) Can I recover from this aside from closing the terminal"
    – DJMcMayhem
    Feb 21 '17 at 17:20

If you're looking for why it jams your terminal it's because :r! reads a command from your terminal and inserts it into the buffer. Since it's trying to insert the output of the vi command, it's waiting for vi to finish. But all it does is open another instance of vi, which never returns.

Is it legal?

Technically, yes. :r! takes a valid shell command and vi is a valid shell command. It's just not advised because of the aforementioned behavior.

See :help :r! for more info.

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.