Wednesday, June 6, 2012

Re: Can vim be made to start with selected files already open?

On Wed, June 6, 2012 06:41, Marc Weber wrote:
>> Thank you Marc. You forget that I'm an idiot. I understand very little
>> of the language you guys speak. I read the readme for this but I
>> understood very little of it either. This is not backhanded criticism.
>> Just stating the facts. I appreciate your generosity, and when I do
>> understand you're always very helpful.
>
> mkdir my-dir
> echo 'e /tmp/foo.txt' > my-dir/.vimrc
> cd my-dir
> vim
>
> Then Vim will ask:
> (Do you want to source my-dir/.vimrc? [y/n])
>
> But it'll ask this once only.
>
>
>> > Option 4)
>> > Use faster ways to open files such as glob open provided in sample rc
>> of
>> > vim-addon-manager - or do :r! find then gf on a path ..
>
> fast glob implementation (requires tlib library):
>
> fun! FastGlob(glob)
> let g = '^'.a:glob.'$'
> let replace = {'**': '.*','*': '[^/\\]*','.': '\.'}
> let g = substitute(g, '\(\*\*\|\*\|\.\)',
> '\='.string(replace).'[submatch(1)]','g')
> let cmd = 'find | grep -e '.shellescape(g)
> " let exclude = a:exclude_pattern == ''? '' : ' | grep -v -e
> '.shellescape(a:exclude_pattern)
> " let cmd .= exclude
> return system(cmd)
> endf
> noremap \go :exec 'e '. fnameescape(tlib#input#List('s','select file',
> split(FastGlob(input('glob pattern, curr dir:','**/*')),"\n") ))<cr>

I think you'll be faster, not to use an extra grep command, but rather
use finds -name/-regex switch

regards,
Christian

--
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

No comments:

Post a Comment