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?
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?
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.
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.
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.
cd
and then running Exp
, the explorer always opens the previous explorer window regardless of what my pwd
is. –
Novosibirsk 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?
pwd
when you first start netrw. However, as I explore, I'd like to update the root of the tree, but cannot figure out how to do this. If I close the netrw buffer and reopen it (even when pointing at a specific directory like :Ex ~/new-directory
then I still get the previous buffer with the same tree root. –
Novosibirsk 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
© 2022 - 2024 — McMap. All rights reserved.
cd
and then runningExp
, the explorer always opens the previous explorer window regardless of what mypwd
is. – Novosibirsk