Monday, October 5, 2015

Re: Running vim in batch mode in background

On Sunday, October 4, 2015 at 9:20:52 PM UTC-5, George R Goffe wrote:
> Ben,
>
>
> Thank you for responding.
>
>
> I'm not sure how to read your example. Can you tell me what each part does please?
>
>

Sure.

vim -c : start Vim, run a command after starting
argdo : repeat the following command for all files you start Vim with
source myscript.vim : first repeated command, to run a Vim script (remember, on each file)
| : command separator; this chains together a second command with the first; remember, it's running on each file
update : save the file if there were any changes
*.file : wildcard to launch Vim with all files ending in ".file". This was an example; use your own wildcard or a file list

>
> What I have been doing is 1) make a list of filenames and then 2) insert a vim command invoking a macro in front of each filename and then running the resulting file as a script.

OK that should work as well, it just means more invocations of Vim so it might be slower.

> This single threads vi. Attempting to add an ampersand at the end of each line merely produces an error message and a stopped vi process.
>

It shouldn't; at least I don't think it should. But try in "silent" or "batch" mode by using -s with no script file argument. I'm not sure whether Vim likes running in the background.

>
>
> I have made a script to gather filenames and run this command "vim -n $file -c " " -s /splitons.vim &" with a pause every 7 commands (lucky 7) to let the system catch up. It's working great now.
>

Looks fine to me. Is this giving you problems? You mentioned Vim hanging. Does your script save and quit Vim or leave it running? What is the -c " " for? That doesn't look like a valid command so Vim might have some sort of message up waiting for user input.

Do you mind bottom-posting, in plain text, instead of top-posting in giant-font HTML?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: