Select Page

Introduction

It’s one heck of an error, that’s got no single fix. Let me explain. It is an error message you get in your system when trying to pipe another command when starting a Vim instance. It has something to do with how your OS handles stdin (standard input) and stdout (standard output). Basically, when you pipe a command to Vim, or in other cases, try to use a subshell to capture output from a program or script and pass it to Vim, it won’t be able to process an output. After which, you get stuck and sometimes may totally be unable to surpass this error.

Despite all, there are several fixes based on your situation that could help you come out of this troublesome error. You’ll need to see for yourself which works out for you. But don’t worry. Your pc ain’t getting brain strokes everytime when you see this message.


Inside a Desktop Environment

Exit the Terminal

If you’re facing this message inside a terminal emulator from a Desktop Enviroment, the most obvious way of getting your way around this problem is to simply quit the terminal, by pressing the close button located in the titlebar. Moverover, if you’re using Windows, this shouldn’t be an issue at all. Just know that it is common and won’t cause any troubles to your pc. So simply just quit it and go to bed. If you’re using Linux from a Window manager only, you may not have luck on this one. SO let’s move on.

Using Htop (or any other Task Manager)

If you are unable to quit the terminal no matter what, there’s a round-trip trick that could help you. This is to open up another terminal instance, and fire up htop, the most commonly used task manager in Linux. Let’s take the following example as a practical use case:

When I tried to pipe another command while opening a file using Vim, I get stuck as one would usually do. To now fix this (supposing that I’m unable to quit the terminal in any way), I’ll open up another terminal instance and start the htop program.

Once I’ve done that, I’ll need to search around for something that includes both the running Vim instance on the other terminal which should the pipe command below it same as the one you tried. It should look something like this in my particular case:

Lastly, I can now press F9 and then Enter respectively on my keyboard close the both the instance of Vim and the pipe command, excluding the bash instance running it if you wish to.

Now that killed those processes, I get a prompt to press Enter in the terminal to successfully terminate the problem. Yes, it is both a process, and a problem.


Manually

The last method, is to do it without using any external means. This one is a bit tricky though, but makes it faster in case you’re facing the problem while in a hurry.

Vim has a feature to detach the currently running Vim instance from the terminal and let it stay in the background by pressing Ctrl + Z from a running Vim interface. This use case can be applied to the error message and get your terminal back to normal. But how?

When you first see the message and nothing works while you repeatedly try to press other keys in hope of some light to appear and fix your terminal. Trust me, it won’t work, until you happen to press Ctrl + Z while doing so. However, pressing the once will not work, as I have noticed in my own case. The steps to get it done this way is as follows:

1. Press Ctrl + Z
2. Press Enter key
3. Press Ctrl + Z again

Trust me. I really don’t know either why it works. The closest I could get to an explanation is that, when we First press Ctrl + Z while the terminal is hanged, the terminal returns a verbal output of the command instead of carrying out the function of Ctrl + Z. After that, when we press Enter, the verbal output is overridden by a new layer of command to be executed, and finally when you press Ctrl + Z once again, you now get it’s function to be carried out properly, and see the stopped text which indicated that the Vim instance is now detached. To kill it now, execute the following in your terminal:

$ kill %1

Another Specific Scenario

This is a rare scenario which can occur to you too if you’re unlucky enough. That is, sometimes when trying to execute a terminal command from inside of Vim, you may see the same error. But with bad luck comes good luck – it isn’t as problematic as directly seeing the message in your terminal. Because you are still able to use the regular commands that allow you to quit Vim. If you still can’t however, you can use the very same Ctrl + Z method from the interface to detach the session and the use kill %1 to kill the instance. But this time, you’d probably notice that you won’t need to follow all the 3 steps. Simply pressing Ctrl + Z once will do the job.

Inside a Virtual Terminal (TTY)

This one is a true problem as opposed to seeing the error from a graphical environment, as in a virtual terminal, you won’t be able to quit the terminal. I won’t be able to show you the process for fixing this problem, as from the TTY I will be unable to take any screenshots or recordings. But if you’ve understood the processes in the previous section, this shouldn’t be a problem either as most of the steps are the same.

Using Htop

Just like the previous one, you need to first open another terminal instance. To open another instance from the TTY interface, you need to press “Ctrl + Alt + F2” in your keyboard, as you may already know if you happen to use TTY often. You’ll see that you’re prompted to login using your username and password. After you’ve done so, fire up htop, find the instance of Vim and the other command you tried to pipe, and follow the exact same procedure as last time. Once killing the processes, return back to the previous TTY instance by pressing “Ctrl + Alt + F1“. You’ll now hopefully be able to press Enter and use your terminal as usually once again.

Manually

The manual method mentioned in the previous section works the very same way in a TTY as well. So if you don’t want to use htop, or lets say, you don’t have htop installed in the first place for some reason, you can follow that previous procedure to get your terminal back to normal.

Conclusion

In the end, I’m hopeful that despite whatever scenario you’re facing for this error to occur, you’d be able to fix it with the above mentioned ways. There are even more cases where people get this message not even trying to use Vim, but these fixes will help nevertheless. If you’re still unable to fix this and got stuck, having tried every other way you could, I guess the only remaining option would be to force shutdown your computer. Period.

But hopefully, you won’t need to.