Hello all,

I use "set viminfo='100,<50,s10,h,%" to keep my bufferlist. But when I restart 
Vim I still get an additional [No Name] buffer. I don't want this but found no 
way to tell Vim to not create it. 

Question 1:
Is there any way to tell Vim not to create this initial empty [No Name] buffer 
if other buffers are loaded from the .viminfo file?

I also tried to remove the buffer with a function and autocommand (code below) 
which deletes the buffer just fine but introduces a new problem: The options 
'ft' and 'syn' are not set for the next buffer (buffer 2) which is displayed 
after wiping the [No Name] buffer. That has the effect that this buffer appears 
w/o syntax highlighting until I :edit it. All other buffers behave correctly 
only buffer 2 has the options messed up.

function! LucCheckIfBufferIsNew(...)
  " check if the buffer with number a:1 is new.  That is to say, if it as
  " no name and is empty.  If a:1 is not supplied 1 is used.
  " find the buffer nr to check
  let number = a:0 ? a:1 : 1
  " save current and alternative buffer
  let current = bufnr('%')
  let alternative = bufnr('#')
  let value = 0
  " check buffer name
  if bufexists(number) && bufname(number) == ''
    silent! execute 'buffer' number
    let value = line('$') == 1 && getline(1) == '' ? 1 : 0
    silent! execute 'buffer' alternative
    silent! execute 'buffer' current
  endif
  return value
endfunction
autocmd VimEnter * if LucCheckIfBufferIsNew(1) | bwipeout 1 | endif

(the function is slightly more general than needed for this use case)

Question 2:
How can I delete the buffer and not mess up the options of the next displayed 
buffer?

Technical Info:
The [No Name] buffer in question appears in Vim 7.2 patchs 1-108 (Mac OS X 
Snowleopard built in vim), Vim 7.3 patchs 1-308 (Mac OS X Snowleopard MacVim 
version) in Vim 7.2 patches 1-445 (Debian) and Vim 7.3 patches 1-429 (Debian). 
It does not matter weather I use "--noplugins" or even "-u ./test" on the 
command line (where ./test just contains the line "set 
viminfo='100,<50,s10,h,%").

Thanks for your help
Lucas

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to