我已经将 Vim 配置为如下所示:
+------------------------------------+
| N | Code |
| E | |
| R | |
| D | |
| T | |
| r |-------------------------------|
| e | REPL |
| e | |
+------------------------------------+
每个元素都在它自己的缓冲区中。只有在我退出代码缓冲区时才可以删除 REPL 缓冲区吗?例如,如果我打开和关闭帮助,REPL 应该保留,但是当我关闭代码缓冲区时,REPL 缓冲区也应该关闭。
这就是我现在所拥有的:
let s:code_repl_nrs = {} " A map of (code buffer number) - (REPL buffer number)
let s:last_leaved_buffer_nr = -1 " The number of the last leaved buffer
autocmd BufLeave,BufDelete * let s:last_leaved_buffer_nr = bufnr('%')
autocmd BufUnload * call <SID>StopREPL(s:last_leaved_buffer_nr) " Stop the REPL when closing the code buffer
"" Stops a REPL given the number of the current buffer
function! s:StopREPL(buffer_nr)
let l:repl_nr = get(s:code_repl_nrs, a:buffer_nr . '', -1) " Get the number of the REPL buffer
if l:repl_nr != -1
exec l:repl_nr . 'bdelete!'
endif
endfunction
当我使用:h
时,REPL 关闭。我怎样才能防止这种情况?