1

How do I keep the terminal buffer from showing up in my airline list of buffers? I assume airline just pulls buffers from what normally shows up in :ls. But I actually don't want the terminal to show up in that list.

As you can see in this image there's an airline s "tab" to the right of the settings.json "tab" (airline has a setting to show buffers as tabs). This s tab is the terminal buffer that I had opened earlier with neoterm mapping for :botright Ttoggle. However, I really do not want this to show up in my list of buffers that I can tab through.

enter image description here

1 Answer 1

1

This seems to get me what I want. I think neoterm relies on the terminal buffer being in the buffer list. I just made my buffer tab cycle key mapping check to see if the new buffer that was cycled to was the terminal buffer, if so do another bnext/bprev. Also needed an autocmd for getting into and out of insert mode depending on buftype. Airline has a var you can set for not displaying the terminal buffer to the buffer 'tabs'

    let g:airline#extensions#tabline#ignore_bufadd_pat = 'gundo|undotree|vimfiler|tagbar|nerd_tree|startify|!|term'

    au BufEnter * if &buftype == 'terminal' | startinsert | else | stopinsert | endif
    function! PrevBufferTab()
      bprev
      if &buftype == 'terminal'
        bprev
      endif
    endfunction
    function! NextBufferTab()
      bnext
      if &buftype == 'terminal'
        bnext
      endif
    endfunction
    " Cycle buffer tabs in airline's tab bar
    nnoremap <c-a> :call PrevBufferTab()<cr>
    nnoremap <c-x> :call NextBufferTab()<cr>
    " kill buffer tab
    nnoremap <c-q> :bp <bar> bd #<cr>
1
  • Thanks for this! I added also the quickfix buffer to be skipped with if &buftype == 'terminal' || &buftype == 'quickfix'
    – K.S.
    Commented Apr 1, 2021 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.