rahmat
rahmat

Reputation: 1757

vim script throw E488: Trailing Characters

I have this on my vimrc:

" close all buffer except active buffer
function! CloseAllBuffersButCurrent()
  let l:curr = bufnr('%')
  let l:last = bufnr('$')
  if l:curr > 1 | silent! execute '1,'.(l:curr-1).'bd' | endif
  if l:curr < l:last | silent! execute (l:curr+1).','.l:last.'bd' | endif
endfunction
command! BO :call CloseAllBuffersButCurrent()<CR>

This was used to close all buffer except the active one. Everytime I invoke it using :BO, the function worked but I always got "E488: Trailing Characters" message.

How to fix it? Thanks.

Upvotes: 1

Views: 516

Answers (1)

phd
phd

Reputation: 95038

command is not mapping so you don't need <CR>:

command! BO :call CloseAllBuffersButCurrent()

Upvotes: 5

Related Questions