@@ -111,7 +111,7 @@ nmap tt :%s/\t/ /g<CR>
111
111
" """"新文件标题
112
112
" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
113
113
" 新建.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()"
115
115
" "定义函数SetTitle,自动插入文件头
116
116
func SetTitle ()
117
117
" 如果文件类型为.sh文件
@@ -139,7 +139,7 @@ func SetTitle()
139
139
call append (line (" ." )+ 4 , " ************************************************************************/" )
140
140
call append (line (" ." )+ 5 , " " )
141
141
endif
142
- if & filetype == ' cpp'
142
+ if expand ( " %:e " ) == ' cpp'
143
143
call append (line (" ." )+ 6 , " #include<iostream>" )
144
144
call append (line (" ." )+ 7 , " using namespace std;" )
145
145
call append (line (" ." )+ 8 , " " )
@@ -148,6 +148,11 @@ func SetTitle()
148
148
call append (line (" ." )+ 6 , " #include<stdio.h>" )
149
149
call append (line (" ." )+ 7 , " " )
150
150
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
151
156
if &filetype == ' java'
152
157
call append (line (" ." )+ 6 ," public class " .expand (" %:r" ))
153
158
call append (line (" ." )+ 7 ," " )
0 commit comments