Question

The title sums it up, really. I'd like to know how to set the current root of the tree when browsing files using netrw in vim.

Any ideas?

Was it helpful?

Solution 2

Per the documentation for netrw, use the ex command

:Ntree [dirname]

Assuming you have netrw installed, one can obtain more information on this using help

:help Ntree

Often times, I will just change the current work directory using the ex command

:cd [dirname]

Next, I start the explorer (ex command again)

:Exp

***Addendum***********

To update your version of netrw, I would just follow the directions that the author, Charles Campbell, posted on www.vim.org.

OTHER TIPS

You can also use "gn" mapping to change the current directory to the folder under your cursor.

CHANGING TREE TOP netrw-ntree :Ntree netrw-gn {{{2

One may specify a new tree top for tree listings using

    :Ntree [dirname]

Without a "dirname", the current line is used (and any leading depth information is elided). With a "dirname", the specified directory name is used.

The "gn" map will take the word below the cursor and use that for changing the top of the tree listing.

quite old thread, but maybe someone find this information useful that currently you can use c to change to current dir.

If you want to always change pwd while browsing around with netrw you could use: let g:netrw_keepdir = 0

What do you mean by "the current root of the tree"?

Do you want a faster or more deterministic way to browse directories in netrw than the usual --/foo<CR><CR>/bar<CR><CR>/baz<CR><CR>?

Or do you want to be able to open netrw in a specific directory?

Or something else?

netrw v151 supports changing the treetop (root of tree):

:Ntree [directory]

and one may use the "-" key to have the treetop become the parent of the current tree. See http://www.drchip.org/astronaut/vim/index.html#NETRW for the latest netrw.

As of the doc of netrw, just type cd to make the browsing directoyr the current directory:

*netrw-c* : This map's name has been changed from "c" to cd (see |netrw-cd|).
          This change was done to allow for |netrw-cb| and |netrw-cB| maps.

Note: the doc seems inconsistent, because the quick reference has a line with

 c  Make browsing directory the current directory        |netrw-c|

... but cd works as explained above.

You can also press "C" while the cursor is on the directory you'd like to make the current home.

From NerdTree help

" Filesystem mappings~                  |~                                                                                                                                                                                                                                                                                   
" C: change tree root to the            |~                                                                                                                                                                                                                                                                                   
"    selected dir                       |~                                                                                                                                                                                                                                                                                   
" u: move tree root up a dir            |~                                                                                                                                                                                                                                                                                   
" U: move tree root up a dir            |~                                                                                                                                                                                                                                                                                   
"    but leave old root open            |~                                                                                                                                                                                                                                                                                   
" r: refresh cursor dir                 |~                                                                                                                                                                                                                                                                                   
" R: refresh current root               |~                                                                                                                                                                                                                                                                                   
" m: Show menu                          |~                                                                                                                                                                                                                                                                                   
" cd:change the CWD to the              |~                                                                                                                                                                                                                                                                                   
"    selected dir                       |~                                                                                                                                                                                                                                                                                   
" CD:change tree root to CWD  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top