I’m using Vim 7.3 with the MRU plugin.
With this plugin, when you type :MRU you see a new window with the most recent used files. That’s cool, but I want something more specfic than that:
Let’s say that I’m working with just one window. I first open file A, then file B, then file C.
Now that I’m currently on file C, I want to go back to file B and then back to file A with a keystroke, just like a back button on a browser history. And I want to do the same to move forward, from file A back to file B and finally back to file C, like I’m playing with a browser history.
How can I do that?
The file A, B and C are called “buffers” in Vim parlance. What you want is the ability to jump directly from buffer to buffer or the ability to select the buffer you want to jump to.
Jumping from one buffer to another is easy. It’s done with the
:bcommand or its cousins:Selecting a buffer from a list is also easy:
:ls<CR>shows a numbered list of buffers and waits for a command. At that point, you type:b <number><CR>or:<number>b<CR>to jump to the selected buffer. You can add the following mapping to your~/.vimrcto make the whole process quicker:There is also a rather large number of buffer switching plugins at your disposal (the rest of the page is also full of interesting info).
I use CtrlP, which is not listed, when I can and the mapping above when I can’t.