""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " File Name: headerGatesAdd.vim " Abstract: A (G)VIM plugin which automatic inser C/C++ header gates . " Author: 帅得不敢出门 email:tczengming at 163.com " Version: 1.0 " Last Change: 2011.1.19 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Avoid reloading {{{ if exists('loaded_cinsert_header_gates') finish endif let loaded_cinsert_header_gates= 1 " }}} " Python required {{{ if !has('python')" finish endif "}}} if !exists('g:insert_extern_c_flag') let g:insert_extern_c_flag=1 endif " insertHeaderGates {{{ function! s:insertHeaderGates() python << EOF import vim import re #定位到头部说明信息(如版权,作者)的下一行 def getInsertLine(): b=vim.current.buffer n = len(b) start = b[0][0:2] i=0 if start == '//': i=1 while( i1: return i i=0 line = b[i] while start == '/*': while (iinsertHeaderGates() autocmd BufNewFile *.{h,hpp} call insertHeaderGates()