If I close all buffers, I'm left with the terminal window, which automatically opens whenever I open Vim.
I would like it close automatically when I exit Vim.
I see that on the NERDTree repo, they included a code that will automatically close NERDTree if it is the last window:
" 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
I want similarly that: if the terminal window is the last window, Vim close it automatically.
Edit: If the terminal window and NERDTree are the last windows, I want them both to close automatically.
Because I do not want to quit them manually every time I finish editing. In addition, I have the following code for NERDTree in my vimrc:
" 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
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif