@@ -111,7 +111,7 @@ nmap tt :%s/\t/ /g<CR>
111111" """"新文件标题
112112" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
113113" 新建.c,.h,.sh,.java文件,自动插入文件头
114- autocmd BufNewFile *.cpp,*.c ,*.sh,*.rb,*.java,*.py exec " :call SetTitle()"
114+ autocmd BufNewFile *.cpp,*.[ch] ,*.sh,*.rb,*.java,*.py exec " :call SetTitle()"
115115" "定义函数SetTitle,自动插入文件头
116116func SetTitle ()
117117 " 如果文件类型为.sh文件
@@ -139,7 +139,7 @@ func SetTitle()
139139 call append (line (" ." )+ 4 , " ************************************************************************/" )
140140 call append (line (" ." )+ 5 , " " )
141141 endif
142- if & filetype == ' cpp'
142+ if expand ( " %:e " ) == ' cpp'
143143 call append (line (" ." )+ 6 , " #include<iostream>" )
144144 call append (line (" ." )+ 7 , " using namespace std;" )
145145 call append (line (" ." )+ 8 , " " )
@@ -148,6 +148,11 @@ func SetTitle()
148148 call append (line (" ." )+ 6 , " #include<stdio.h>" )
149149 call append (line (" ." )+ 7 , " " )
150150 endif
151+ if expand (" %:e" ) == ' h'
152+ call append (line (" ." )+ 6 , " #ifndef _" .toupper (expand (" %:r" ))." _H" )
153+ call append (line (" ." )+ 7 , " #define _" .toupper (expand (" %:r" ))." _H" )
154+ call append (line (" ." )+ 8 , " #endif" )
155+ endif
151156 if &filetype == ' java'
152157 call append (line (" ." )+ 6 ," public class " .expand (" %:r" ))
153158 call append (line (" ." )+ 7 ," " )
0 commit comments