Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change order for :bnext and :bprevious in vim?

Tags:

vim

In vim I'm opening 3 files in buffers: A,B,C (in this order). I'm going back to buffer B, I open buffer D (:e d) while being in B (so now I'm in D). But when I use :bprevious I go to C, but I would like to go to last visited buffer - B.

Is it possible to change buffer swiching order to use order of they activity, as in example above?

like image 572
Sławosz Avatar asked Nov 18 '11 15:11

Sławosz


People also ask

How do I go back to the previous line in Vim?

To jump back to line # 300 or previous position press CTRL-O (press and hold Ctrl key and press letter O). To jump back forwards press CTRL-I (press and hold Ctrl key and press letter I).

How do I go to previous vi?

Press <shift-N> to go back to the previous occurrence of your find term.

How do I rearrange tabs in Vim?

You can use :tabmove followed by the tab number to move past. For example, :tabmove 3 will make the current tab move past the 3rd. :tabmove 0 moves to the beginning and :tabmove (without a number) moves to the end.

How do you replace one word with another in Vim?

Search for text using / or for a word using * . In normal mode, type cgn (change the next search hit) then immediately type the replacement. Press Esc to finish. From normal mode, search for the next occurrence that you want to replace ( n ) and press . to repeat the last change.


2 Answers

I don't think it's possible to change the buffer list's order without some possibly dirty heavy lifting but there are quite a lot of buffer navigation plugins available.

This one, from the list, seems to adress your problem perfectly.

If you don't need to go to the previouser-previouser-previouser-previouser buffer, you might consider <C-^> to switch to the previous one.

like image 108
romainl Avatar answered Oct 14 '22 05:10

romainl


You can use the argument list. See :help :args.
You can edit a file and put in the argument list easily with the :argedit command. The argument list behave exactly what you would like.
You can use :n command to edit the next file in the argument list and :N (or :prev) to edit the previous. It's even shorter then :bp and :bn !

+1 for editing the alternate file as @romainl said. It's really fast !

like image 36
kissgyorgy Avatar answered Oct 14 '22 05:10

kissgyorgy