0

I'd like to be able to use the same shortcut to jump to a file in NERDTree and close NERDTree. I have no experience with VimL and could use some help.

domi91c
  • 1,962
  • 4
  • 23
  • 38

2 Answers2

0

Add the following to you vimrc

set autochdir
noremap  <F2> :NERDTreeTabsToggle<cr>

The first command will automatically change the current directory to be the same the same as the file you are editing.

The second command will then set F2 to toggle toggles NERDTree on/off for all tabs. you can use any key i prefer F2.

byaruhaf
  • 4,128
  • 2
  • 32
  • 50
0

Just say you want to do this with <leader>n:

" This in your ~/.vimrc
nnoremap <leader>n :NERDTreeFind<CR>

" This in ~/.vim/ftplugin/nerdtree.vim
nnoremap <buffer> <leader>n :NERDTreeClose<CR>

Substitute whatever you want for <leader>n.

Greg Hurrell
  • 5,177
  • 23
  • 27