Regards,
Chip Campbell
Perhaps if you try...
au BufEnter * if line("$") == 1 && getline(1) == "" | Explore | endif
Regards,
Chip Campbell
Hmmm. I expect this doesn't work because the autocommand fires when the
buffer is being created but isn't necessarily put in a window yet, which
obviously is needed for :Explore.
> Actually the reason I want this auto command is that I don't need to
> type the full path to start editing it. Instead, I thought I would
> say :new and I can just browse and pick the file to edit.
Perhaps just get in the habit of using :Sex instead of :new?
And/or use some cabbrev magic?
Ben.
That sounds like it could be the case. I wish there was a timing-based
list of events in the docs. In autocmd.txt, under "autocommand-events",
there's an almost-timing-based list, but BufEnter and BufNew are way
down the list. Anyway, when I tried running Jeenu's BufNew triggering
of Explore with netrw's debugging enabled -- well, it doesn't appear
that netrw was even called.
Regards,
Chip Campbell
Don't you ever create a new file from scratch? Or use an empty buffer
for things which you want to use temporarily but never even write to
disk? I often do: when I want to paste into a program other than Vim
some character which I don't know how to produce with my admittedly
versatile but not universal Belgian keyboard, for instance the French œ
(oe) digraph which you just saw, or the "vulgar" ¼ ⅕ ¾ fractions, I open
a [No Name] buffer in a new split-window in Vim, type the required
characters there using digraphs, keymaps, or even |i_CTRL-V-digit|, and
bring them back over the clipboard. Then :q! is my friend to close the
temporary split window. No need to wake up netrw in all that. When I do
want a directory listing, I use ":new ./" or maybe ":sv $VIMRUNTIME",
IOW I explicitly "edit a directory".
If you want the current directory, or the directory of the current file,
you don't need to type its full path anyway:
current directory:
:new ./
directory of the current file:
:new %:p:h
your home directory:
:new ~/
etc.
Best regards,
Tony.
--
ARTHUR: (as the MAN next to him is squashed by a sheep) Knights! Run away!
Midst echoing shouts of "run away" the KNIGHTS retreat to cover with
the odd
cow or goose hitting them still. The KNIGHTS crouch down under cover.
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD
I don't know what the BufNew event is good for, but it gives me crap:
augroup foo
au!
au BufNew * call AddSomeText()
augroup end
func! AddSomeText()
put = 'Text added from BufNew event!'
endfunc
" EOF
:new
modifies text in the old window (gVim 7.1.315).
--
Andy
I believe that's as expected:
:help BufNew
> NOTE: When this autocommand is executed, the
> current buffer "%" may be different from the
> buffer being created "<afile>".
Ben.