It seems you are looking for the option NERDTreeHijackNetrw
, as explained in the NERDTree documentation:
If set to 1, doing a :edit <some directory> will open up a "secondary" NERD tree instead of a netrw in the target window. Secondary NERD trees behaves slightly different from a regular trees in the following respects: 1. 'o' will open the selected file in the same window as the tree, replacing it. 2. you can have as many secondary tree as you want in the same tab.
If you are looking for something beyond that you could achieve it based on the API offered by the plugin:
4. The NERD tree API *NERDTreeAPI* The NERD tree script allows you to add custom key mappings and menu items via a set of API calls. Any scripts that use this API should be placed in ~/.vim/nerdtree_plugin/ (*nix) or ~/vimfiles/nerdtree_plugin (windows). The script exposes some prototype objects that can be used to manipulate the tree and/or get information from it: g:NERDTreePath g:NERDTreeDirNode g:NERDTreeFileNode g:NERDTreeBookmark See the code/comments in NERD_tree.vim to find how to use these objects. The following code conventions are used: * class members start with a capital letter * instance members start with a lower case letter * private members start with an underscore See this blog post for more details: http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html
One possible solution is to create a mapping that retrieve the path from the file under the cursor and use the :edit
on it.