SpiRail
SpiRail

Reputation: 1415

Vim: blank screen on subsequent shell commands

I run shell commands from vim all the time using the !command syntax

When you have the results of one command on the screen and you press ! again (with the intention of performing another command). The whole screen goes black except for the command at the bottom.

Why does this happen? In my opinion, It would be more useful to still have the output of the previous shell command on the screen.

Is there a setting that stops the screen from going blank for subsequent commands?

Upvotes: 0

Views: 2101

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172520

If you mean that when the previous external command output is still visible, and Vim shows the "Press ENTER or type command to continue" prompt, :! will indeed clear the output. That is because Vim's command line (which you enter with :) is always at the bottom of the screen. There's no way around this.

To help you with your problem, many people will recommend using a terminal multiplexer like screen or tmux, and use a split of Vim and a separate shell in two windows. You can then use the multiplexer's commands to move to / from Vim and resize the corresponding windows based on your needs.

Without that, using just Vim, a workaround would be to capture the command output in a scratch buffer:

:new | 0read !ls

is the basic command; there are more elaborate implementations in plugins or on the Vim Tips Wiki.

There are also plugins (like ConqueShell, thanks Kent!) that try to implement a terminal inside Vim, but those have limitations over the mentioned multiplexers.

Upvotes: 3

Related Questions