Does something like this exist?:
let @p = "0D:!ping -c1 8.8.8.8\<CR>"<SLEEP 1 SECOND>"\<CR>iJust pinged a DNS Server\<ESC>"
- And let me read the
ping
result. So things likegs
are not possible...
To address your requirement of being able to read the output, I'd move the delay into the shell command:
:let @p = "0D:!ping -c1 8.8.8.8 ; sleep 1\<CR>iJust pinged a DNS Server\<Esc>"
I don't think there's any other way of introducing a delay into the middle of Vim's :!
command: control doesn't return to the macro until after it's completed and the output has been removed from the screen.
Alternative solutions would be to use D. Ben Knoble's suggestion of reading the output into the buffer itself and then removing it again after the delay, or to move everything into a function where you can do whatever you like and then (if necessary) call this from the macro. This would be a cleaner solution.
You can use the gs
command to introduce a delay. This command can be prefixed with a count to specify the number of seconds. Refer to the help page for more information. For example, to introduce a 2 second delay, you can use the following:
let @p = "0D:!ping -c1 8.8.8.8\<CR>2gsiJust pinged a DNS Server\<Esc>"
ping
Prompt. So before the <CR>
not after^^ But thanks for showing me that I can replace ^M
with \<ESC>
:)
:read !ping …
instead?:read !ping
,gs
,:delete
or something similar (plus it would be in your buffer, so you could also just show the results and edit as desired).