When I run :maps that use ! to execute linux commands, the vim display is suspended to show the command output in the underlying container (xterm in my case). When the mapping terminates, any shell messages it may have produced are immediately obscured by the restored vim buffer.

Is there a handy Ctrl- or Ex command that will toggle the underlying xterm so that I can read such shell messages?

  • 1
    This is not default behavior IIRC—usually a « hit Enter » prompt is given. Can you edit an example of such a mapping into your question? I also believe one of the shortmess options turns off the hit enter prompt: please also give the value of 'shortmess' in your question.
    – D. Ben Knoble
    Jul 2 '19 at 1:08

The command :suspend (same as Ctrl-Z, for obvious reasons) will suspend vim and return you to your shell. If used just after a :! command, you can usually see the output. If your terminal has scrollback (via the emulator or tmux, for example), that may be useful.

But, as far as I know, shell commands that produce output should result in a « Hit ENTER to continue » prompt, unless 'shortmess' contains certain flags or the command was prefixed with :silent.

Another somewhat common cause of missing output is a double <CR> at the end of mappings that is meant to avoid the prompt. Removing it can get back the output.

  • Right all through, especially 'HIT ENTER...' And why did I ask this question? Because in mappings that run a shell command I automatically add a second <cr> at the end so I don't have to press Enter to get back to Vim. Duh! my face is red.
    – user985675
    Jul 2 '19 at 18:58
  • @user985675 good catch! I hadn’t considered that case.
    – D. Ben Knoble
    Jul 2 '19 at 19:04

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.