TLDR: Can I make Vim automatically switch to the buffer that I just opened?

Please tell me if I'm using Vim wrong in this case or something.

I'm currently working with foo.txt. I want to look at bar.txt. I type :badd bar.txt. I now have a new buffer for bar.txt, but I'm still looking at foo.txt, and I'm annoyed that Vim didn't switch to bar.txt.

The thing I just opened should be the focus, not put in the background. It seems like every other piece of software acts differently. I use set hidden, so it shouldn't matter if I have unsaved changes in foo.txt.

  • 1
    :e bar.txt opens bar.txt and switch to the buffer.
    – Alex Kroll
    Mar 22, 2019 at 20:37

1 Answer 1


You can use :edit or :e to edit a file:

:e bar.txt

:badd will simply add the buffer/document to the buffer list and not focus the buffer like you want.

For more help see:

:h :e
:h :badd
:h buffers
  • Thank you very much. I bet I learned that from vimtutor, but forgot. No wonder I couldn't find the answer on Google; editing is different than badding.
    – aswine
    Mar 22, 2019 at 19:42

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.