tags:

views:

68

answers:

2

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?

+1  A: 

I use mapping for NERDTree and in this way when I open it always opens in current dir

" NERDTree mappings
 nnoremap <silent> <F9> :NERDTreeToggle <cr>
 inoremap <silent> <F9> <Esc>:NERDTreeToggle <cr>

But if you open a file like gvim ~/other/dir/file NERDTree will open current dir from where gvim was called. So this is not a real solution to your problem.

Perhaps if you cd in working dir before calling gvim will solve your problem. In this case even your au VimEnter * NERDTree in _vimrc must work as you espect .

About changing directory and setting working dir set autochdir read here

kfl62
+2  A: 

NERDTree provides several global commands to manipulate with tree buffer (see :help NERDTreeGlobalCommands). There is NERDTreeFind among them, which behaves a lot like NERDTree command, but opens tree buffer in the directory containing the file opened in the current buffer.

So, in order to achieve the desired effect you've described, you can simply change the auto-command to

au VimEnter * NERDTreeFind
ib
+1 much cleaner solution then mine :)
kfl62