NERDTree shows in viewport disk c: regardless from which disk do I open the file.
When I use gvim in windows I open files using:
gvim.exe --remote-tab-silent [FILE]
I'm loading NERDTree with this line in _vimrc:
au VimEnter * NERDTree
Can NERDTree automaticaly change drive to correct drive somehow?
So if you want change the drive in NERDTree I advise you to perform the following 2 steps: cd drive:\ :NERDTree . where drive is the drive letter you want to change to, and . means change the NERDTree directory to the current working directory.
In NERDTree, press m to bring up the NERDTree Menu, and then you should see an option, labeled o , to open the current node with the system editor associated with that file or directory.
Actually, my last answer does not work because once the NERDTree have been opened, it does not open again in the new buffer dir. It must work similarly to NERDTreeFind but it does not have a Toggle feature.
I made a function and mapped it to my key and now it works perfectly even opening the Ruby project if you have the vim-rails plugin.
Add this to your vimrc:
function! NTFinderP()
"" Check if NERDTree is open
if exists("t:NERDTreeBufName")
let s:ntree = bufwinnr(t:NERDTreeBufName)
else
let s:ntree = -1
endif
if (s:ntree != -1)
"" If NERDTree is open, close it.
:NERDTreeClose
else
"" Try to open a :Rtree for the rails project
if exists(":Rtree")
"" Open Rtree (using rails plugin, it opens in project dir)
:Rtree
else
"" Open NERDTree in the file path
:NERDTreeFind
endif
endif
endfunction
"" Toggles NERDTree
map <silent> <F1> :call NTFinderP()<CR>
It should work now.
Previous answer below:
You could map the key you use to open NERDTree like this(in .vimrc):
map <silent> <F1> :NERDTreeToggle %:p:h<CR>
This maps my F1 key to toggle(open/close) NERDTree using the path of the currently active buffer. If no buffer is open, it opens in the currently launched Macvim directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With