3

Often when editing LaTeX files, you are constantly switching between your .tex, .sty and .bib files which are often in their own buffer.

To navigate between those, I use the :bn and :bp commands which I have remapped to <Tab> and <S-Tab> for convenience.

Yet, vimtex by default enables the quickfix buffer.

How can I skip the quickfix buffer when buffer switching (the buffers are not in split windows)?

  • 2
    Why not create dedicated local mappings for tex files? Is there a way to reliably predict the names of some of the files, or otherwise prepopulate a list of choices? Have you considered using args and argnext instead? – D. Ben Knoble Apr 1 at 23:26
  • 3
    Ben's suggestion is pretty good I think you are facing what they call an XY problem. To add to his suggestion I think you could have a look at vim-projectionist: If I'm not mistaken it allows you to define different alternate files which could be useful here (but I never used it and I'm not 100% sure this is what you need) – statox Apr 2 at 8:30
4

You can adapt either of the answers here to skip the quickfix:

Here's my one:

function! BSkipQuickFix(command)
  let start_buffer = bufnr('%')
  execute a:command
  while &buftype ==# 'quickfix' && bufnr('%') != start_buffer
    execute a:command
  endwhile
endfunction

nnoremap <Tab> :call BSkipQuickFix("bn")<CR>
nnoremap <S-Tab> :call BSkipQuickFix("bp")<CR>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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