nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 1b19089917cc3e0a81d3294fead2424c419d545c
parent c8be9458dddb986dc17a3f5a00aaf29cd60b1b5f
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date:   Sun, 31 Jan 2021 00:19:58 -0500

Add new FAQ and answer: How to prevent buffers replacing NERDTree. (#1215)

* Add new FAQ and answer: How to prevent buffers replacing NERDTree.

* Update version number in change log.
Diffstat:
MCHANGELOG.md | 1+
MREADME.markdown | 8++++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -5,6 +5,7 @@
         - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
 -->
 #### 6.10
+- **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215)
 - **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214)
 - **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213)
 - **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207)
diff --git a/README.markdown b/README.markdown
@@ -156,6 +156,14 @@ autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTr
     \ quit | endif
 ```
 
+### How can I prevent other buffers replacing NERDTree in its window?
+
+```vim
+" If another buffer tries to replace NERDTree, put in the other window, and bring back NERDTree.
+autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
+    \ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
+```
+
 ### Can I have the same NERDTree on every tab automatically?
 
 ```vim