Are there any plugins in Vim that allow you to move through the list of buffers you have had open in order? Ctrl-6
does it for two files, but I want something that does more. For example, if I open buffers a, b, c, d in order, I want to type something to back to c, back to b, forward to c again, etc.

- 7,741
- 7
- 39
- 51
-
Just curious of what the differences you want compared to Ctrl-O/Tab (see: http://vim.wikia.com/wiki/Jumping_to_previously_visited_locations) is this not sufficient enough to go back-and-forth? Or you need more functionality than Ctrl-O? – HidekiAI Feb 14 '17 at 21:56
2 Answers
This is available via built-in vim commands: bprevious
and bnext
, or bp
and bn
.
Using your example, open the files, and type :bp to go to the buffer with c, then :bp and you're in buffer b, and :bn gets you back to buffer c.
Also convenient: type e.g. :b1 to go to buffer 1, if it exists, and :b myFile.txt
to go to the buffer containing the file name myFile.txt
.
bprevious
and bnext
always follow the ordering of the buffer list. You can observe this ordering with the :ls
command. Notice that each buffer is assigned an increasing number. bprevious
and bnext
will follow this ordering regardless of how many windows and/or tabs you're moving between.
e.g. if you've opened a, b, c, d as in your example, and you have two split windows, the first with buffer a and the second with buffer b, a bnext
in the first window will put you in buffer b, and a bnext
in the second window will put you in buffer c.

- 58,613
- 19
- 146
- 147
-
bp and bn are just what I needed. I was making it too hard, rather than just looking for built-in functionality. Thanks. – Kyle Heironimus Jul 13 '12 at 21:17
-
1Ok, after looking a bit, bp and bn are NOT what I need. If I have several windows open and move around a bit, bp does NOT bring up buffers I want. As a matter of fact, it brings up seemingly random ones. Am I missing something? – Kyle Heironimus Aug 11 '12 at 04:44
-
@KyleHeironimus see the edit. vims buffer handling/movement facilities are pretty primitive, not even a most-recently-used facility. Folks that need more use buffer-management plugins like [Ctrl-p](http://kien.github.com/ctrlp.vim/). For others it's enough to just keep track of filenames and buffer numbers. – pb2q Aug 11 '12 at 17:47
-
ctrl-p is great, but if sometimes I'm just tracking code down the call stack and want to just go back two buffers, for example, without messing with ctrl-p or even remembering what file I was in. – Kyle Heironimus Aug 13 '12 at 14:25
I found a simple plugin that does what I want in this question.

- 1
- 1

- 7,741
- 7
- 39
- 51