mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 04:07:03 +08:00
docs: update FAQ snippets containing quit
command. (#1417)
This commit is contained in:
parent
6ad85ec29b
commit
fbb71fcd90
|
@ -150,6 +150,24 @@ autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in
|
|||
|
||||
### How can I close Vim or a tab automatically when NERDTree is the last window?
|
||||
|
||||
Because of the changes in how Vim handles its `autocmd` and layout locking `quit` command is no longer available in Vim9 auto commands, Depending on which version you're running select one of these solutions.
|
||||
|
||||
__NeoVim users should be able to choose either one of them!__
|
||||
|
||||
#### Vim9
|
||||
|
||||
```vim
|
||||
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
|
||||
```
|
||||
---
|
||||
```vim
|
||||
" Close the tab if NERDTree is the only window remaining in it.
|
||||
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
|
||||
```
|
||||
|
||||
#### Vim8 or older
|
||||
|
||||
```vim
|
||||
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user