Say, I opened a file named file1.txt present in some directory X, and after editing, I closed the file.
Now after sometime, I have opened another file named file2.txt present in some another directory Y.

Now How to open the file1.txt using vsplit if I can't remember the directory X. Is there a way?


2 Answers 2






This means split and edit previous buffer. It will split the current buffer horizontally and open the previously edited file in the top buffer.

The full command allows you to jump back to the Nth previous buffer:



:sbp N

If you are unsure of how many "files ago" you edited that other file, you may then use


repeatedly until you get back to the file you once edited (if you have edited many files in-between during the same session).

This only work within one vim session.


Did you close Vim when you closed file1.txt?

Below will work, if you didn't close Vim completely:

If you are still in the same Window and e.g. you have foo.txt and another file bar.txt in an other split window. You could close foo.txt with :wq. Then you have the bar.txt still opened. Now you could open a file baz.txt with :e /path/baz.txt. With :bp you could jump to the previous buffer (:bn to the next). So now if you have baz.txt opened in your Vim you could :vsplit it with the previous buffer with the command :vsplit | bp

But if you closed Vim completely, then this solution wouldn't work.

  • I think OP asked more about how to open a previously opened file if he doesn't remember the path to it. Your solution still suggests to open it with an exact path :e /path/op/doesnt/remember. So I would not say it's a solution after all.
    – ddnomad
    Apr 2, 2017 at 20:25
  • If you didn't close Vim, you could open a closed buffer with :bp, doesn't matter in which directory you are atm. In that case you could open it my way. Say, if you have a NERDtree on the left, and file1.txt on the right, you could close file1.txt with :wq and then open file2.txt with NERDtree or :e /path/file2.txt. Then when file2.txt is open, with vsplit | bpit would work. But if you closed Vim completely when you closed file1.txt, then my solution does not work.
    – chloesoe
    Apr 2, 2017 at 20:27
  • Indeed, so I would suggest you to edit your answer highlighting important parts of it and removing irrelevant ones. Important parts here are: if OP hasn't closed vim completely, he can use :vsplit | bp to split with a previous buffer (which is actually still opened).
    – ddnomad
    Apr 2, 2017 at 20:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .