sent 01:15:56 23 August 2011, Tuesday
by Tim Chase:
> which should give you an ":E" command that works like ":e" except
> that if you give it one or more filespecs, it loads them all and
> leaves you on the last one. E.g.
Try :E %, it does not work. You should use expand(...) instead of glob(...)
because expand(...) expands % and some other specials and also globs. You also
definitely forgot fnameescape() and use `len(...)' where you can write either
`!empty(...)' or just `a:0'.
// Not very important, but you can't :E filename with newlines.
Original message:
> On 08/22/2011 01:15 PM, AK wrote:
> > On 08/22/2011 01:47 PM, Tim Chase wrote:
> >> Should the last file in the resulting filespec
> >> override the others (as if ":e f[12].txt" did the same thing as ":e
> >> f1.txt" followed by ":e f2.txt")?
> >
> > My guess is that if you asked 100 vim users, 90-95 would be fine with
> > either leaving first or last file in current window and loading the
> > rest in buffer list.
> >
> > But for this command, out of thousands, it can't be done!
>
> Not too hard to throw together something that will end up editing
> all of them:
>
> function! Edit(really, ...)
> if len(a:000)
> for globspec in a:000
> let l:files = split(glob(globspec), "\n")
> for fname in l:files
> exec 'e'.(a:really).' '.(fname)
> endfor
> endfor
> else
> exec 'e'.(a:really)
> endif
> endfunction
>
> command! -nargs=* -complete=file -bang E call Edit("<bang>",
> <f-args>)
>
> which should give you an ":E" command that works like ":e" except
> that if you give it one or more filespecs, it loads them all and
> leaves you on the last one. E.g.
>
> :E
> :E!
> :E *.txt
> :E! *.txt
> :E *.txt *.html
> :E! *.txt *.html
>
> So, while I wouldn't use, it's a pretty simple function to make
> use of.
>
> -tim
No comments:
Post a Comment