5

When I type :ls, I get a list of buffers with non-sequential, high numbers (I didn't open 800 files):

:ls!
  1      "b(...)" line 67
  2 #    "b(...)" line 90
  3      "b(...)" line 50
  4      "b(...)" line 90
 27u  -  "ControlP" line 8
 77      "b(...)" line 16
 93      "b(...)" line 1
 94      "b(...)" line 209
 99      "b(...)" line 135
104      "b(...)" line 52
109      "b(...)" line 65
110      "b(...)" line 44
112      "b(...)" line 39
113      "b(...)" line 339
114      "b(...)" line 58
130  a   "b(...)" line 186
144      "s(...)" line 51
146      "b(...)" line 6
147      "b(...)" line 359
150      "t(...)" line 1
151      "b(...)" line 123
152      "b(...)" line 178
187      "b(...)" line 581
204      "s(...)" line 1
239u     "2" line 1
244      "b(...)" line 42
258      "b(...)" line 73
278      "t(...)" line 1
281      "t(...)" line 153
308      "t(...)" line 1
313      "t(...)" line 15
314      "v(...)" line 1
315      "s(...)" line 217
318      "b(...)" line 34
325u h-  "NERD_tree_1" line 32
326      "t(...)" line 1
327      "t(...)" line 34
347      "b(...)" line 49
350      "b(...)" line 5
481      "b(...)" line 38
566      "b(...)" line 30
583      "t(...)" line 55
680      "t(...)" line 33
685      "b(...)" line 216
784      "t(...)" line 1
815      "b(...)" line 1
816  a   "b(...)" line 0
878      "f(...)" line 1
879      "b(...)" line 1
880      "f(...)" line 1
881 %a + "[No Name]" line 1
Press ENTER or type command to continue   

Why did this happen?

I don't use :grep. I have the following plugins installed:

  Plugin 'VundleVim/Vundle.vim'
  Plugin 'kien/ctrlp.vim'
  Plugin 'morhetz/gruvbox'
  Plugin 'scrooloose/nerdtree'
  Plugin 'majutsushi/tagbar'
  Plugin 'tomtom/tcomment_vim'
  Plugin 'Shougo/unite.vim'
  Plugin 'tpope/vim-fugitive'
  Plugin 'airblade/vim-gitgutter'
10
  • do you know the buffer names? Dec 3, 2015 at 15:45
  • You almost certainly used :grep or some other command that created unlisted buffers for every matching file.
    – romainl
    Dec 3, 2015 at 15:45
  • Those (...) are real, valid file names that I have opened. Those are fine. I have truncated file names as this is my work computer. I am confuseb by the gaps between them. Dec 3, 2015 at 15:49
  • 1
    It's even easier to switch by partial name.
    – romainl
    Dec 3, 2015 at 22:01
  • 1
    This happens to me when I browse repositories with fugitive. Nerdtree too, not sure about the rest.
    – Steve
    Dec 7, 2015 at 17:26

1 Answer 1

7

It's because of vim-gitgutter.

In order to work correctly with git repos which mess around with line endings, e.g. via core.crlf, I had to change how vim-gitgutter ran its diffs. Previously it passed the contents of the buffer directly to git-diff on stdin, via the second argument to vim's system() call. Now it has to create a temporary file for the buffer's contents and hand the file to git-diff.

Although the temporary file is never read into vim, and is deleted immediately after use, vim still increments the next available buffer number. I find this inelegant but there it is.

As a result, after you have been editing files for a while you end up with high buffer numbers. I agree it's a bit surprising but it doesn't do any harm.

2
  • 3
    Instead of recreating and deleting the temporary file, you could truncate that file and reuse it again and again. That's how I do it for the changes plugin. Dec 16, 2015 at 21:16
  • 1
    I've fixed this now; the buffer numbers no longer increment so rapidly. Jan 18, 2016 at 10:32

Your Answer

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

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