把它放在$MYVIMRC中
function! NumberOfWindows() let i = 1 while winbufnr(i) != -1 let i = i+1 endwhile return i - 1 endfunction function! DonotQuitLastwindow() if NumberOfWindows() != 1 let v:errmsg = "" silent! quit if v:errmsg != "" "echohl ErrorMsg | echomsg v:errmsg | echohl NONE "echoerr v:errmsg echohl ErrorMsg | echo v:errmsg | echohl NONE endif else echohl Error | echo "Can't quit the last window..." | echohl None endif endfunction if has("gui_running") cnoreabbrev <expr> q getcmdtype() == ":" && getcmdline() == 'q' ? 'call DonotQuitLastwindow()' : 'q' cnoreabbrev <expr> qa getcmdtype() == ":" && getcmdline() == 'qa' ? 'call DonotQuitLastwindow()' : 'qa' endif
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。