DZ小明 2017-04-04 14:35 采纳率: 75%
浏览 1414
已采纳

我就想知道为什么我的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条回答

  • devmiao 2017-04-04 15:24
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作