“Press ENTER or type command to continue”: why am I seeing this

vim

I'm familiar with this message when a command's output is more than one line.

However, on one of the systems I use, I see it every time I write with :w, despite having plenty of horizontal space for the message. For example:

enter image description here

This only seems to happen when I use vim in a tmux session, but I can't work out why this should happen. Every other aspect of vim and tmux seems to be working fine. Turns out it has nothing to do with tmux.


Update: I tracked it down to the following line in my vimrc:

set backupdir=/tmp

Using a vimrc that contains only this line is enough to trigger the message when writing to a file. Interestingly, it only happens when I write to an existing file.

Why would this happen, and on this machine only?

Best Answer

Without looking at the exact environment, I can only guess that /tmp does not exist (or is full or has some permission issue) on the culprit machine. When-ever you write to existing file, vim is not able to save the backup, so it is complaining, and then prompting you.

You can check if this is the case by trying one of the following:

  1. See if you can save the file without the prompt using :w!.
  2. See if you can get some error message before the prompt by adding this to .vimrc:

    set cmdheight=N
    

    Try N=2 or 3 or 4, whichever works fine for your environment.

Related Question