首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.vimrc动作关闭

.vimrc动作关闭
EN

Stack Overflow用户
提问于 2009-11-04 13:08:07
回答 1查看 2.2K关注 0票数 11

是否可以使用类似于“vim关闭/退出”的-Event来执行vim退出之前的一些最后命令?

我在配置中使用这一行,让vim设置我的屏幕标题:

如果$TERM=='xterm-color‘

exe "set title titlestring=vim:%t“exe "set title t_ts=\k t_fs=\\”

endif

但是当我结束vim时,标题设置为:“感谢飞行Vim”(无论来自何方)。

我的目标是,将标题重置为旧的--如果可能的话--如果可能的话--设置为类似于使用"exe"-Command的"bash“。

所以..。在vim中有类似于“近距离事件”的东西吗?

谢谢:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-11-04 13:18:39

是的,有一个“近距离事件”--实际上是其中两个。

引用vim的:help {event}

代码语言:javascript
复制
            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-Event.

工作样本如下所示:

代码语言:javascript
复制
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()

此外,您还可以使用v:挂起捕捉异常退出情况。

票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1673649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档