是否可以使用类似“vim-close / exit”-Event的东西在vim退出之前执行最后的命令?
我在配置中使用这一行,让vim设置我的屏幕标题:
if $ TERM =='xterm-color'
exe "set title titlestring=vim:%t"
exe "set title t_ts=\<ESC>k t_fs=\<ESC>\\"
万一
但当我关闭vim时,标题设置为:“感谢飞行Vim”(不管是来自......)
我的目标是,将标题重置为旧标题 - 如果可能 - 如果不是 - 设置为“bash”与“exe”-Command
所以...在vim中有类似“近距离事件”的东西吗?
谢谢 :)
是的,有一个“近距离事件” - 实际上有两个。
引用vim的 :help {event}:
Startup and exit
|VimEnter| after doing all the startup stuff
|GUIEnter| after starting the GUI successfully
|TermResponse| after the terminal response to |t_RV| is received
|VimLeavePre| before exiting Vim, before writing the viminfo file
|VimLeave| before exiting Vim, after writing the viminfo file
你是在追求 VimLeave-事件。
一个工作样本看起来像这样:
function! ResetTitle()
" disable vim's ability to set the title
exec "set title t_ts='' t_fs=''"
" and restore it to 'bash'
exec ":!echo -e '\033kbash\033\\'\<CR>"
endfunction
au VimLeave * silent call ResetTitle()
另外你可以使用 五:死亡 捕捉异常退出案件。
是的,有一个“近距离事件” - 实际上有两个。
引用vim的 :help {event}:
Startup and exit
|VimEnter| after doing all the startup stuff
|GUIEnter| after starting the GUI successfully
|TermResponse| after the terminal response to |t_RV| is received
|VimLeavePre| before exiting Vim, before writing the viminfo file
|VimLeave| before exiting Vim, after writing the viminfo file
你是在追求 VimLeave-事件。
一个工作样本看起来像这样:
function! ResetTitle()
" disable vim's ability to set the title
exec "set title t_ts='' t_fs=''"
" and restore it to 'bash'
exec ":!echo -e '\033kbash\033\\'\<CR>"
endfunction
au VimLeave * silent call ResetTitle()
另外你可以使用 五:死亡 捕捉异常退出案件。