代码: 全选
" 和 $VIMRUNTIME/ftplugin/*.vim 一样,防重入,这点倒好说
if exists("b:did_ftplugin_after")
finish
endif
let b:did_ftplugin_after = 1
" 关键的 SID ,要传出一个 SID 竟如此麻烦,或者说要获得自己的 SID
function! s:GetSID()
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_GetSID$')
endfunction
" undo_ftplugin 是必须的,看 $VIMRNTIME/ftplugin.vim
let b:undo_ftplugin_new = b:undo_ftplugin .
\ " | call <SNR>" . s:GetSID() . "_UnDo_FtPlugin_After()" .
\ " | unlet! b:did_ftplugin_after"
let b:undo_ftplugin = b:undo_ftplugin_new
unlet b:undo_ftplugin_new
“ =============
function! s:UnDo_FtPlugin_After()
" ……
" 脚本逻辑略