vim脚本抛出E488:尾随字符

rah*_*mat 1 vim

我在我的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>
Run Code Online (Sandbox Code Playgroud)

这用于关闭除活动缓冲区之外的所有缓冲区.每次我用它调用:BO的函数工作,但我总是得到"E488:末尾加"的消息.

怎么解决?谢谢.

phd*_*phd 5

command没有映射所以你不需要<CR>:

command! BO :call CloseAllBuffersButCurrent()
Run Code Online (Sandbox Code Playgroud)