No buffer 3 in VIM?

238 views Asked by At

So I open VIM:

$ vim

And then I open 3 files:

:e file1.txt
:e file2.txt
:e file3.txt

As expected, there are 3 buffers, but they are numbered like this:

  • 1: file1.txt
  • 2: file2.txt
  • 4: file4.txt

Any ideas?


$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 25 2013 19:55:22)
Included patches: 1-875
Compiled by ArchLinux
Huge version with GTK2 GUI.  Features included (+) or not (-):
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    
+farsi           +mouse_netterm   +syntax          
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/libpng15 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng15 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2  -I/usr/local/include  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic  -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfreetype -lfontconfig  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lnsl   -lacl -lattr -lgpm -ldl  -L/usr/lib -llua -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic   -lruby -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib

And:

$ cat ~/.vimrc
syntax on
set number
set mouse=a
call pathogen#infect()
filetype plugin indent on

On VIM:

:ls!
  1      "file1.txt"                    line 1
  2 #    "file2.txt"                    line 1
  3u a-  "-MiniBufExplorer-"            line 0
  4 %a   "file3.txt"                    line 1
Press ENTER or type command to continue

Cause: This "issue" is caused by MiniBufExplorer being opened after :e file2.txt.

MiniBufExplorer is not open when vim starts, neither is it when I :e file1.txt. But apparently, when 2 or more files are open, it opens automatically, occupying the next buffer (hence buffer 3 being taken).


Solution: Use a different plugin that wouldn't use up a buffer.

1

There are 1 answers

1
romainl On

So you opened 4 buffers, closed the 3rd and ask why you get 3 buffers with no buffer number 3?

Buffers are numbered at their creation and those numbers never change: if you create buffers 1, 2, 3 and 4 and delete buffer 3 you get 3 buffers: 1, 2 and 4.

Now seems to be the perfect time to read :h buffers.