9

I recently discovered the option switchbuf and tried to use it but I can't say if I don't understand how it should work or if it actually doesn't work on my Vim.

About the different possible values, the doc says:

useopen If included, jump to the first open window that
              contains the specified buffer (if there is one).
usetab Like "useopen", but also consider windows in other tab pages.

I have then used set switchbuf=useopen,usetab and the following commands in a new vim instance:

  • Open a first buffer :e file1
  • Split the screen :split
  • Open a second buffer :e file2
  • Go back to the first buffer :e file1 (I have also used :bN)

The last commands to go to the first buffer open it in the second split. From what I understand from the doc the commands should place the cursor to the first split where the buffer is already open thanks to useopen. Also the behavior is the same when I try the same commands with tabs instead of splits.

  • Is this behavior the expected one?
  • If so could you explain what this option should do?
  • If not I know that I'll have to debug my .vimrc but maybe is there a common setting known to interfere with switchbuf?
9

'switchbuf' is only honored by quickfix commands (like :cc) and buffer-splitting commands (like :sb).

It doesn't affect :buffer and other "regular" buffer-related commands.

  • 1
    Oh I see. As the doc says first This option controls the behavior when switching between buffers. and only several lines later mentions quickfix commands and sb I thought that it was in addition of the regular buffer commands. Thanks! – statox Sep 27 '15 at 20:38

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.