【问题标题】:No buffer 3 in VIM?VIM 中没有缓冲区 3?
【发布时间】:2013-04-04 03:18:52
【问题描述】:

所以我打开 VIM:

$ vim

然后我打开 3 个文件:

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

正如预期的那样,有 3 个缓冲区,但它们的编号如下:

  • 1:file1.txt
  • 2:文件2.txt
  • 4:file4.txt

有什么想法吗?


$ 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

还有:

$ cat ~/.vimrc
syntax on
set number
set mouse=a
call pathogen#infect()
filetype plugin indent 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

原因:这个“问题”是在:e file2.txt之后打开MiniBufExplorer引起的。

在vim启动时MiniBufExplorer没有打开,我:e file1.txt时也没有。但显然,当打开 2 个或更多文件时,它会自动打开,占用下一个缓冲区(因此占用缓冲区 3)。


解决方案:使用不会用完缓冲区的其他插件。

【问题讨论】:

  • 不要粗鲁,但这有关系吗?
  • @PeterRincker,有点(让我再输入一个缓冲区,而无需向:b 添加 2-3 位数字)
  • 如果有帮助,可以使用:b 命令的缓冲区名称的一部分。将它与制表符补全和通配符结合起来,您可以在不使用缓冲区编号的情况下走得更远。
  • @PeterRincker,对,但我只是想知道为什么会发生这种情况:)
  • 如果您真的按照您所说的去做,就不应该发生这种情况。请将$ vim --version 的完整输出和~/.vimrc 的完整输出添加到您的问题正文中。

标签: vim minibufexplorer


【解决方案1】:

所以你打开了 4 个缓冲区,关闭了第 3 个缓冲区并问为什么你得到 3 个缓冲区而没有第 3 个缓冲区?

缓冲区在创建时被编号,并且这些数字从不改变:如果您创建缓冲区 1、2、3 和 4 并删除缓冲区 3,您将获得 3 个缓冲区:1、2 和 4。

现在似乎是阅读:h buffers的最佳时机。

【讨论】:

  • 不,我没有打开 4 个缓冲区,只有 3 个,是的,我知道当你关闭一个缓冲区时,它不允许你再次使用该缓冲区 ID,直到重新启动。跨度>
猜你喜欢
  • 2013-09-03
  • 2018-05-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-02
  • 2013-07-19
  • 2019-01-09
相关资源
最近更新 更多