sinat_36118270
DZ小明
2017-04-04 14:35

我就想知道为什么我的vim中这样的文件出不来头文件和版权信息?

  • linux
  • vim

我就想知道为什么我的vim中这样的文件出不来头文件和版权信息?

新文件标题
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile .cpp,.[ch],*.sh,*.java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1,"#########################################################################")
call append(line("."), "# File Name: ".expand("%"))
call append(line(".")+1, "# Author: Nick_Duan")
call append(line(".")+2, "# mail: dlm291459214@outlook.com")
call append(line(".")+3, "# Created Time: ".strftime("%c"))
call append(line(".")+4, "#########################################################################")
call append(line(".")+5, "#!/bin/bash")
call append(line(".")+6, "")
else
call setline(1, "*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: Nick_Duan")
call append(line(".")+2, " > Mail: dlm291459214@outlook.com ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
endif
if &filetype == 'cpp'
call setline(1, "*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: Nick_Duan")
call append(line(".")+2, " > Mail: dlm291459214@outlook.com ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
call append(line(".")+6, "#include")
call append(line(".")+7, "using namespace std;")
call append(line(".")+8, "")
endif
if &filetype == 'c'
call setline(1, "*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: Nick_Duan")
call append(line(".")+2, " > Mail: dlm291459214@outlook.com ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
call append(line(".")+6, "#include")
call append(line(".")+7, "")
endif
if &filetype == 'java'
call setline(1, "*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: Nick_Duan")
call append(line(".")+2, " > Mail: dlm291459214@outlook.com ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
call append(line(".")+6,"public class ".expand("%"))
call append(line(".")+7,"")
endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答