nerdtree auto focus to file when opened in new tab

Sairam picture Sairam · Nov 25, 2010 · Viewed 9.8k times · Source

I am using NerdTree on Linux . I would like to jump from the nerd tree buffer to the file buffer after opening a file in a new tab using 't'. I need to press 'Ctrl+W+W' all the time.

Any idea about how to have vi execute C-W-W after a new buffer is created .

Sairam

Answer

Yohann picture Yohann · Oct 12, 2013

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