jteng2127
jteng2127

Reputation: 63

Is there a way to set the root directory of explorer (netrw) to the working dirctory of the current window in Vim?

For example, there are two splited windows on screen, explorer at some/path and a file with path another/path/123.txt and I want to set explorer path to another/path by do something in 123.txt

Is there a way to set the root directory of explorer (netrw) to the working dirctory of the current window in Vim? (Maybe there is a way in NERDtree can do something similar to what I hope to do, just out of curious)

thanks for answering. and my English isn't very good, sorry for that

Upvotes: 0

Views: 478

Answers (1)

Peter Rincker
Peter Rincker

Reputation: 45107

One way is to close the tree explorer window and then split+explore from the 123.txt file

:only|Sexplore %:h<cr>
<c-w>o:sp %:h<cr>

A semi-related simple mapping (and setting) which copies Tim Pope's vim-vinegar's - for fast directory exploring is approximately:

noremap - :e %:h<cr>
let g:netrw_banner = 0

With this you would do <c-w>o<c-w>s-

For more help see:

:h :only
:h :Sex
:h :_%
:h ::h

Upvotes: 1

Related Questions