Tuesday, June 5, 2012

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

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


:r! find
This command just runs finds and insterts its output into the currernt
buffer. r means read. Then you can use / ? vim search and gf to open
the files being represented as names in the current buffer by.


If you say "I'm an idiot" you speak a language I don't understand. It
does not tell me where to start explaining what I'm talking about.

Marc Weber

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