1

I usually open files one in a single vim application. Occasionally, I open multiple files at once to fix some mistakes in batch, for example, after static analyzer.

If I was edited files in the order b, c, a, and run from a command line vim a b c, I'll see that my current buffer is b, previos buffer is c, but buffers will be opened and assigned their numbers sequentially in the order a, b, c. In other words, the order of numbered buffer list is the same as the order in the command line, but the order in which buffers are actually opened (starting buffer, :bn and :bp) is the same as I previously opened individual files, starting from the last one.

I heavily use w | bw sequence and I rely on what previous/next buffer is. It's become even more annoying when you open 50+ files and you have to read output from an analyzer upside-down or in a random order, because vim desided to order buffers this way. The command example I use to run a "mass fix session" is vim $(awk -F: '{print $1}' analyzer.out | uniq)

To manually override this behaviour I have to remove .viminfo file, but from time to time it contains useful information like last used commands which I use a lot.

How to prevent Vim to have this behaviour? Or any command I could run to reset it? When using session management, it's quite fine to restore a file I previously was, but it's quite useless and annoing in my case.

Currently I use MacVim 8.1.280 (151) in GUI mode, but, unfortunately, it's not a MacVim-specific issue and running vim on Linux or FreeBSD have the same behavior.

Different installations share only YCM and I don't believe that it responsible for this odd behavior.

3
  • What if instead you use analyzer.out as a quickfix file, and move around with :cnext ?
    – D. Ben Knoble
    Oct 7, 2018 at 19:22
  • It's a quite good idea, if you give me a hint how to use output from a file for the :cnext command as it coult be quite heavy to run command from Vim itself (e.g. output from tox).
    – Eir Nym
    Oct 7, 2018 at 20:03
  • The bigger picture, I want to be able to clear the order without damaging .viminfo file
    – Eir Nym
    Oct 7, 2018 at 20:03

1 Answer 1

1

I'm having a little trouble following your use case but based on reference to buffers and the viminfo file it seems that you must be talking about the "Buffer list" section of viminfo.

You can tell Vim to not save that particular set of data but otherwise continue saving the rest of the data as before by altering the 'viminfo' setting. In particular, if you exclude the character % from the value list the Buffer list section will go away. An easy way to do it: :set viminfo-=%.

Weird thing is that saving that Buffer list section is not default behavior. Are you sure it isn't being set in a vimrc file or plugin or something? If it is then just edit the line and remove the %.

Oh, and if I guessed wrong and you're talking about a different section of viminfo then just go to :h 'viminfo' and find the proper symbol to set/update/remove as prescribed.

11
  • Thank you for a response. My :set viminfo? is '100,<50,s10,h
    – Eir Nym
    Oct 7, 2018 at 23:33
  • The order of files is the same as the order in the command line, but the order in which buffers are actually opened (starting buffer, :bn and :bp) is the same as I previously opened individual files, starting from the last one.
    – Eir Nym
    Oct 7, 2018 at 23:33
  • @EirNym Really? Because that's what I first thought you meant but a) I've never heard of that behavior and b) I couldn't reproduce that behavior...thus I thought you must be talking about the other thing. What are you doing the first time...the session that sets the order in stone? Anything unusual? If deleting viminfo helps do you know what section is the cause?
    – B Layer
    Oct 7, 2018 at 23:41
  • Could it be a jumplist?
    – Eir Nym
    Oct 7, 2018 at 23:42
  • You could try negating the jump list with '0.
    – B Layer
    Oct 7, 2018 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.