Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change root in NERDTree

Tags:

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 is not changed.

Do you know how to change the root forever?

like image 821
xralf Avatar asked Apr 28 '11 11:04

xralf


People also ask

How do I change directory in NERDTree?

Use Vim's built-in :cd command to change directory, followed by the NERDTree CD command (note: that's a normal-mode mapping, not an Ex : command.) (Note that tab completion will work here to complete the directory name.) Then use CD in the NERDTree pane to use the current directory as the new root.

How do you switch windows in NERDTree?

(1) Thus, if your edit window is to the right of the NERDTree window, you would use: ctrl + W l to go to right window and ctrl + W h to go to left window. or ctrl + w twice to toggle between the two.

How do I change the working directory in Vim?

Step 1: using autochdir 'autochdir' 'acd' boolean (default off) global When on, Vim will change the current working directory whenever you open a file, switch buffers, delete a buffer or open/close a window. It will change to the directory containing the file which was opened or selected.

How do I rename a file in NERDTree?

To rename a file in NerdTree, navigate to it, then press mm . It will open a prompt with the old full path already written for you, which you can modify to type the new name of the file.


1 Answers

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.

like image 104
romainl Avatar answered Nov 14 '22 15:11

romainl