On Saturday 25 April 2009 1:50 pm, Manfred Lotz wrote:
>
> Hi,
> I had
> autocmd BufEnter * lcd %:p:h
> in my ~/.vimrc
>
> However, when using netrw this yields an error.
>
>
>
> My workaround is:
>
> function Lcd()
> let b = bufname("%")
> let pat = ":\/\/"
>
> if ! (b =~ pat)
> lcd %:p:h
> endif
> endfunction
>
> autocmd BufEnter * call Lcd()
>
>
> My question as a vim newbie: Is this a good solution or is there a much
> simpler and mores idiomatic way to solve the issue?
the simplest of all: upgrade your netrw
you'll see a version for netrw in the banner -- currently mine
reads v136h -- if your netrw reports anything less than that, i
recommend an upgrade -- visit
http://mysite.verizon.net/astronaut/vim/index.html#NETRW
for the absolute latest and greatest netrw
the reason i recommend an upgrade is that very recently there was a
bugfix to netrw that addressed the autochdir option -- i had turned
'autochdir' on, and it was causing problems for me in netrw -- i
started using the BufEnter autocmd to lcd to %:p:h as a work
around, much as you are, but netrw was fixed and there's no reason
i am aware of that i can't go back to using 'autochdir'
hth,
sc
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---