Re: How to wait for VIM to finish parsing document?
- On Tuesday, April 16, 2013 12:12:09 PM UTC-5, Viminator wrote:
> I'm writing a small Vimscript that will open a number of files, indent them (gg=G), and then save them.Vim is single-threaded, your problem is NOT caused by any timing issues
> I've noticed that oftentimes, the first couple of files do not get indented correctly, even if the command works fine when executed manually. It looks as if the indentation command is being executed before the file is fully parsed, or perhaps before the syntax plugin finishes loading.
> I've tried adding a manual "sleep" to the beginning of the command, but this doesn't seem to make a difference.
> Anyone know what might be causing this issue, and how I can force VIM to finish loading plugins / parsing before the command runs?
unless your indent script shells out to a background task that you
explicitly do asynchronously.
Most likely there is a problem with your command, or you've suppressed the
autocmds that set filetype or syntax or the like (maybe implicitly).
If you're using :bufdo or :argdo, see the note at :help :bufdo and
Note: While this command is executing, the Syntax
autocommand event is disabled by adding it to
'eventignore'. This considerably speeds up editing
If your indent script depends on the syntax highlighting you may need to
manually run the syntax autocmd for the file. I think :doautocmd can be
used to do this easily.
If this doesn't fix your problem, please give the exact command you are
running in case there is something else wrong with it.
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@....
For more options, visit https://groups.google.com/groups/opt_out.