diff --git a/F.A.Q..md b/F.A.Q..md index bbf4e99..a0cac49 100644 --- a/F.A.Q..md +++ b/F.A.Q..md @@ -29,4 +29,15 @@ Use the `t` and `T` mappings in the NERDTree window. ## How can I close NERDTree window after opening a file from it? Use this NERDTree setting: `let NERDTreeQuitOnOpen = 1`. However if you usually want NERDTree to stay open, but sometimes want it to close after opening a file, you can use one of these option. 1. Use the NERDTree keys: `go` followed by `q`. -1. You can map another key to do `goq` for you: `autocmd FileType nerdtree nmap d goq` \ No newline at end of file +1. You can map another key to do `goq` for you: `autocmd FileType nerdtree nmap d goq` + +## How can I make sure vim does not open files and other buffers on NerdTree window? + +```vim +" If more than one window and previous buffer was NERDTree, go back to it. +autocmd BufEnter * if bufname('#') =~# "^NERD_tree_" && winnr('$') > 1 | b# | endif +``` +If you are using vim-plug, you'll also need to add these lines to avoid crashes when calling vim-plug functions while the cursor is on the NERDTree window: +```vim +let g:plug_window = 'noautocmd vertical topleft new' +``` \ No newline at end of file