openEuler系统之shell脚本注释模版配置方法

时间:2024-10-05 18:35:44
" 开启自动命令功能 filetype plugin indent on syntax on " 自动插入注释模板 autocmd BufNewFile,BufRead *.sh,*.cc,*.py,*.java exec ":call SetTitle()" function! SetTitle() let fileType = expand('%:e') " 根据文件类型插入不同的注释模板 if fileType == 'sh' " Shell script call setline(1, "#!/bin/bash") call setline(2, "##########################################################") call setline(3, "# File Name: ".expand("%")) call setline(4, "# Version: V1.0") call setline(5, "# Author: jeven") call setline(6, "# Email: admin@") call setline(7, "# Created Time: ".strftime("%F %T")) call setline(8, "# Description:") call setline(9, "##########################################################") call setline(10, "") elseif fileType == 'cc' " C++ source call setline(1, "// File Name: ".expand("%")) call setline(2, "// Version: V1.0") call setline(3, "// Author: jeven") call setline(4, "// Email: admin@") call setline(5, "// Created Time: ".strftime("%F %T")) call setline(6, "// Description:") call setline(7, "") elseif fileType == 'py' " Python source call setline(1, "# File Name: ".expand("%")) call setline(2, "# Version: V1.0") call setline(3, "# Author: jeven") call setline(4, "# Email: admin@") call setline(5, "# Created Time: ".strftime("%F %T")) call setline(6, "# Description:") call setline(7, "") elseif fileType == 'java' " Java source call setline(1, "/* File Name: ".expand("%")) call setline(2, " * Version: V1.0") call setline(3, " * Author: jeven") call setline(4, " * Email: admin@") call setline(5, " * Created Time: ".strftime("%F %T")) call setline(6, " * Description:") call setline(7, " */") call setline(8, "") endif endfunction