2009-11-04 6 views
11

vim이 종료되기 전에 마지막 명령을 실행하기 위해 "vim-close/exit"-Event와 같은 것을 사용할 수 있습니까?.vimrc action onclose

경우 $의 TERM == 'xterm이나 색'

exe "set title titlestring=vim:%t" 
exe "set title t_ts=\<ESC>k t_fs=\<ESC>\\" 

ENDIF

:

나는 정력 내 화면 제목을 설정할 수 있도록하기 위해, 내 설정이 라인을 사용

하지만 vim을 닫으면 제목이 다음과 같이 설정됩니다. "Vim을 날려 주셔서 감사합니다"(...에서 온 모든 ...)

내 목표는 가능한 경우 이전 제목으로 제목을 재설정하는 것입니다. 그렇지 않은 경우 "exe"로 "bash"와 같은 것을 설정합니다. - 명령

그래서 "닫기 Vim에서 "- 이벤트"?

고마워요 :)

답변

12

네, 실제로 "닫기 이벤트"가 있습니다. 도움이 {이벤트} :

  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() 

당신이 V를 사용할 수 있습니다. 는 & titleold = 대체 (에 getcwd(), $ HOME은, "~", '') 정력 것 같다 보자

+0

큰 큰 고맙습니다 ... 비트는 내가 VimLeave didnt 한 작업 후 시원한 대안을 발견했습니다 출구에서 복원되는 titleold : 이제 ~/my/path를 설정합니다. Thats cool :) – Beerweasle

+0

@Beerweasle 댓글이 완전히 정확하지 않습니다. 'let & titleold = substitute (getcwd(), $ HOME, "~", "")' 아이디어에 감사드립니다 !! – Alf