Reputation: 1757
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
Reputation: 95038
command
is not mapping so you don't need <CR>
:
command! BO :call CloseAllBuffersButCurrent()
Upvotes: 5