On Fri, Feb 4, 2011 at 7:44 PM, Marc Weber <[email protected]> wrote:
> Excerpts from Michael(Xi Zhang)'s message of Sat Feb 05 02:31:15 +0000
> 2011:
> > function s:Searchwordgl()
> >
> > let searchstring = expand("<cword>") "search string under the
> cursor
> >
> > let searchdirlist = readfile('sdir.txt','',6) "read directories
> into
> > list
> > string
> >
> > if searchstring != ""
> > endif
> >
> > endfunction
>
>
> > let searchdir = join(searchdirlist) " join the list into
> > execute "vimgrep " searchstring searchdir
>
> spaces will cause trouble.
> Consider using
> join(map(copy(searchdirlist)), 'fnaameescape(v:val)'))
> instead
>
> Also 6 lines is bad. Maybe do
>
> , 7)
>
> if len(list) > 6
> throw "something went wrong. file has too many lines"
> endif
>
> Yours
> Marc Weber
>
> After modify, tested!
function s:Searchwordgl()
let searchstring = expand("<cword>")
let searchdir = ''
for line in readfile("sdir.txt",'',6)
let searchdir .= fnameescape(line).'*.[csh] '
endfor
if searchstring != ""
execute "vimgrep " searchstring searchdir
endif
endfunction
--
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