7

How to open a previously opened buffer in Vim?

I've 4 buffers, say buf1 to buf4.

Currently I've opened buf1 and then I open buf3 executing :b3.

Now, how do I go back to buf1 (the previously opened buffer) without executing :b1?

Ctrl+P will go to buf2, the previous buffer in the list.

Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
  • 1
    I would suggest you look at the following related post: [vim, switching between files rapidly](http://stackoverflow.com/q/16082991/438329). In particular the part referring to using `:b {partial-name}` (there is a nice picture too!). – Peter Rincker Aug 20 '15 at 17:20

1 Answers1

11
:b#

Opens the previously opened buffer.

Repetitive use of the command toggles between the buffers.

Thanks to Related questions on this site!

Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
  • 6
    Alternatively, `` (or `` on some keyboards). – romainl Aug 18 '15 at 10:18
  • @romainl: Cool. This works on my keyboard. Is it keyboard specific or _vimrc specific? – Sagar Jain Aug 18 '15 at 10:41
  • 1
    Sweet. Just goes to show that there's always something new to learn about vim. I've been content to use :bn and :bp for next and previous buffers respectively, but this could be handy in many situations. – labyrinth Aug 19 '15 at 03:04
  • MRU buffers! The `cd -` of Vim :) (I've been searching for this for a while) – icc97 Apr 17 '17 at 21:23