Search code examples
vim

Cannot disable "Press ENTER or type command to continue" message


I have the following command:

command! FilesUpdateMRU :execute '!${MYSCRIPTS}/file -m'

The script executes and at the end I see the following message:

Press ENTER or type command to continue

This is expected, but I want to disable this message. I know there are already threads with this kind of discussion and I have read them and tried the following:

  • set cmdheight=2
  • set shortmess+=F and and set shortmess=F and set shortmess= and set shortmess=a set syntax=on

None of this helps, vim waits for me to press a key. The only thing that helps is silent+redraw:

command! FilesUpdateMRU2 :silent execute '!${MYSCRIPTS}/file -m' | redraw!

The question is: how do I figure out the reason and get away from this message? It looks like I am missing something.

My .vimrc:

set cmdheight=2
set shortmess=
set nomore
set formatoptions-=cro

command! FilesUpdateMRU :execute '!${MYSCRIPTS}/file -m'
command! FilesUpdateMRU2 :silent execute '!${MYSCRIPTS}/file -m' | redraw!

Environment:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 10 2020 20:32:49)
macOS version
Included patches: 1-503, 505-680, 682-2292

Solution

  • From :help press-enter:

    This message is given when there is something on the screen for you to read,
    and the screen is about to be redrawn:
    - After executing an external command (e.g., ":!ls" and "=").
    [...]
    

    Basically, you will still get that message as long as you print the output of the external command. If you don't care about that output, then you can simply :help :call :help system():

    command! FilesUpdateMRU :call system('${MYSCRIPTS}/file -m')
    

    which executes the external command without echoing its output.