Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove the default empty buffer from vim?

Tags:

vim

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:

enter image description here

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

like image 281
Tamás Szelei Avatar asked Sep 11 '11 20:09

Tamás Szelei


People also ask

How to remove all active buffers in Vim at once?

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.

Why do people use BW instead of quit in Vim?

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.

How do I delete multiple buffers at once in Linux?

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.

How do I delete a buffer in Visual Studio Code?

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).


1 Answers

I don't have your problem on

  • linux, gvim - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 24 2011 07:07:34) Included patches: 1-35
  • windows gvim - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 9 2008 18:46:22) MS-Windows 32-bit GUI version with OLE support

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
like image 88
sehe Avatar answered Sep 30 '22 17:09

sehe