K.S.Sreeram wrote:
Gerald Lai wrote:
For Netrw v98, this hack seems to make it work as requested:
Doesn't work for me :(
I installed the Decho plugin, and noticed that the 'cd' command inside
netrw works, but looks like something else is resetting the directory
back to the original value!
Is there some way I can 'hook' into the inbuilt cd/lcd commands so that
I can insert some print statements to see what is going on?
Regards
Sreeram
Didn't you have an autocommand with :cd %:p:h in it? If % is a
directory, that would get you to its parent. If 'autochdir' and the
mechanism provided by netrw aren't working, then you may need something
more complicated, e.g.:
function s:GoToFileDir(file)
if isdirectory(a:file)
exe "lcd" a:file
else
exe "lcd" expand(a:file . ":p:h")
endif
endfunction
autocmd BufRead,BufNewFile,BufFilePost *
\ call <SID>GoToFileDir(<amatch>)
Best regards,
Tony.