Whenever I work with multiple buffers, there is always one empty. I would like to not have that if I open a file with vim from the command line (i.e. I don't want to create a new file, or choose to create a new file by naming it first and starting vim with that name). How can I do this?
Edit:
I'm launching gvim the following way:
I have an alias in my bashrc: alias g="gvim --remote-silent"
I open files from the command line with: g name-of-file
At this point (if I didn't already have an instance of gvim open), I have two buffers:
Edit2:
Platform is Linux Mint, version is: VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 24 2011 07:07:39).
I updated my NERDTree plugin as David suggested, but it didn't help. Other plugins I use: Pathogen, a, doxygentoolkit, nerdtree, snipmate, vim-rails, ack_plugin, easymotion, protobuf, sparkup, yankring, bufexplorer, matchit, rainbow, surround, clang_complete, nerdcommenter, repeat
With this set, vim will prompt you to save file changes on close. :bufdo is a useful command that performs another command on all active buffers. Combining the :bufdo command with the :bw/:bd command lets you remove all active buffers at once.
I tend to use :bw because like the idea of completely removing the buffer from memory, and I don't make much use of marks, buffer-specific option settings, etc, to the point of needing them to remain after closing my buffer. Like the :quit (:q) command, Vim will give an error if the buffer has changed.
There is command to do exactly that: :bdelete or just :bd. By default it will unload current buffer. To unload other buffer, first get the list of all buffers with :buffers command, and after that you can specify the number after :bd to remove it. Also :bd + space + tab allows completion using buffer name. Show activity on this post.
One option is to first switch to another buffer ( :bp, :bn, or :b#, for instance) and then delete the first (alternate) buffer with :bd# . Alternatively, the script below defines the :Bclose command that deletes a buffer, while keeping the current window layout (no windows are closed).
I don't have your problem on
You are probably looking at a bug.
You might be able to debug things by cleaning your $MYVIMRC (temporarily) and running gvim --noplugin
.
Alternatively inspect all settings (like bufhidden
and other suspect parties)
:set
:setglobal
and see from which script/plugin they are being set (bufhidden
as an example only here):
:verbose set bufhidden
:verbose setglobal bufhidden
You might also inspect autocommands (that might prevent buffers from being wiped)
:verbose au
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With