开发者

NERDTree does not open in the directory from which macvim was opened

开发者 https://www.devze.com 2023-01-13 12:02 出处:网络
I upgraded my macvim to 7.3 recently and I can no longer open nerdtree or netw in the directory in which macvim was opened, it always opens in my home directory.

I upgraded my macvim to 7.3 recently and I can no longer open nerdtree or netw in the directory in which macvim was opened, it always opens in my home directory.

For example,

If I open macvim in /users/me/test/project dir, I want the NERDTree root to be /Users/me/test/project and not /Use开发者_开发知识库rs/me.

Any ideas?


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.


I had this problem after upgrading janus. simply adding this to my .gvimrc fixed it:

set autochdir

This will set the working directory to the current file.

More info here: http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file


I did this

(all changes in .vimrc)

  1. Enabled NERDTree as default.

    autocmd VimEnter * NERDTree
    
  2. Put this script I got from github in .vimrc. This will make vim AND NERDTree buffer quit with :q

  3. Say, your project folder is /home/user/my-project, then do this:

    mvim /home/user/my-project/README
    

    You wil get the parent folder in the NERDTree with the files in it.


This problem (if it is the one I think it is) was fixed in Snapshot 55, so a simple update should fix it.

0

精彩评论

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

关注公众号