2

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
romainl
  • 186,200
  • 21
  • 280
  • 313
KarlsD
  • 649
  • 1
  • 6
  • 12

2 Answers2

2

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.

romainl
  • 186,200
  • 21
  • 280
  • 313
1

I think what you did with :silent is right,

check help page :help :!

Vim redraws the screen after the command is finished, because it may have printed any text. This requires a hit-enter prompt, so that you can read any messages. To avoid this use: > :silent !{cmd} < The screen is not redrawn then, thus you have to use CTRL-L or ":redraw!" if the command did display something. Also see |shell-window|.

Hi computer
  • 946
  • 4
  • 8
  • 19