nerdtree auto focus to file when opened in new tab
You can use so-called autocommands, like:
au BufNew * <command>
It will execute command when new buffer is created. Start from there. Check out vimdoc on the subject.
When vim starts, it opens a window for the file, then it opens another window for NerdTree
.
The easiest way to come back to the main window is just to jump to the previous window like this:
" Start NERDTree
autocmd VimEnter * NERDTree
" Go to previous (last accessed) window.
autocmd VimEnter * wincmd p