On Sunday, June 10, 2012 9:35:16 AM UTC+12, Alexandru Munteanu wrote:
> What seems to take a lot of time (even on just 50 files) is the second
> line (the buffer switch 'b!' command).
> Any idea how I could improve the performance ?
The buffer switch is loading the next buffer, and maybe processing autocommands for the buffer.
If you are going to be processing the same files repeatedly, :set hidden will load them only the first time.
Using :bufdo always suppresses syntax autocommands, and is a clean way to loop through the buffers. For example, in the vim source directory, vim *.c finds 101 files, and sourcing the following completes in 3 s:
let s_search = 'phi'
let g:results = []
bufdo exe 'normal gg' |
\ while search(s_search,'',40000) > 0 |
\ let g:results += [getline(".")] |
\ endwhile
If I've :set hidden, subsequent runs are very quick. In principle, opening the files read only (vim -R) should be quicker, but I didn't notice a difference.
If you don't want to use bufdo, you can invoke stuff prefixed with :noautocmd.
Regards, John Little
--
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
Sunday, June 10, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment