On 2017-07-11, astian wrote:
> zdohnal wrote:
> > Hi,
> >
> > I encountered this issue so I would like to ask if it is bug or it is
> > correct behavior. When I want to save directory listing into other
> > file by command:
> >
> > $ vim . -c "w output-file" -c "q"
> >
> > but output-file is empty in the end. Is it bug or optin -c is cannot
> > be be used with netrw plugin (which is used when I open directory in
> > vim)? When I do it by hand step by step:
> >
> > 1) $ vim .
> > 2) :w output-file
> > 3) :q
> >
> > it works and output-file contains correct data.
>
> Don't know whether it should be considered a bug, but I can explain you
> why it happens.
>
> The function in netrw that checks whether a directory listing should be
> created is s:LocalBrowse and that function does nothing unless
> s:VimEnter was called first, and s:VimEnter itself is triggered by a
> VimEnter event. And VimEnter events fire:
>
> After doing all the startup stuff, including loading .vimrc files,
> executing the "-c cmd" arguments, creating all windows and loading the
> buffers in them.
>
> So basically, your "-c cmd" arguments are executing before netrw has had
> a chance to produce the listing.
>
> This worked for me:
>
> $ vim -c 'call netrw#LocalBrowseCheck(expand("%:p")) | w /tmp/listing | q' .
You can also do this:
vim -c 'au VimEnter * w! output-file | q' .
I originally tried that with --cmd instead of -c, but it didn't work
for the reason you gave in your explanation. That is, --cmd put my
autocommand before netrw's in the list of VimEnter autocommands,
whereas -c put my autocommand after netrw's. Thanks.
Regards,
Gary
--
--
You received this message from the "vim_dev" 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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.