With the release of vim 8, I was wondering if there is a way to execute
Short Answer: No
The Async supported add in vim 8 was for I/O. From
Vim can now exchange messages with other processes in the background. This makes it possible to have servers do work and send back the results to Vim.
Theoretically the issue is that
:g operate on your current buffer. Doing work async would mean that the results would be overridden if you happened to modify the buffer before the "async find-n-swap" completed. You'd have to reload the buffer with
:e! and at that point you've lost the time gained by doing it async.
There is a function call Rereading the documentation, it looks like if vim is "busy" the timeout might be longer, which makes it sound like the operation wouldn't be async and would stop you from inputting during the callback.
timer_start() which you could use to execute a viml function. Using a 0ms timeout would make the task execute immediately and in the background. While the theoretical issue still applies, you could write a function that takes a sequence of file names (from your args list or buffer list) and performs a
:g on them and then reload the files after it has completed.
A better option for that function would be to use
job_start() and call a system command to do the background file manipulation. Then use something like
sed or even better use
ex to perform the operations. Still have the issue with updating your current buffer since it will change in the background and now your buffer will be out of sync, but its an option.