开发者

Change root in NERDTree

开发者 https://www.devze.com 2023-03-01 12:14 出处:网络
I tried to change the NERDTree root with :BookmarkToRoot <bookmark> command and with C letter but when I close vim and open vim the root i开发者_如何学Cs not changed.

I tried to change the NERDTree root with

:BookmarkToRoot <bookmark>

command and with C letter but when I close vim and open vim the root i开发者_如何学Cs not changed.

Do you know how to change the root forever?


You could try something like:

nnoremap <leader>n :NERDTree /path/to/folder<CR>

I have this in my .vimrc:

set autochdir
let NERDTreeChDirMode=2
nnoremap <leader>n :NERDTree .<CR>

so that NERDTree always opens in the current folder.

With the 1st line, the working directory is always the one where the active buffer is located.

With the 2nd line, I make sure the working directory is set correctly.

With the 3rd line, I hit <leader>n to open NERDTree.


As i don't want vim to change directories automatically, i just use:

com! -nargs=1 -complete=dir Ncd NERDTree | cd <args> |NERDTreeCWD

so you can just do a ":Ncd path/you/like/" with path completion.


Quickest what worked form me was just :cd new-root, close :q and reopen :NERDTree.


I simply changed the “Working Directory:” of my GVim launcher to where I wanted the root to be.

Change root in NERDTree

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号