vim 配置shell模板

编辑 ~/.vimrc定制脚本基本格式模板
额外推荐设置:

set autoindent
set tabstop=4
set expandtab

.vimrc shell模板实现函数如下:

autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
    if expand("%:e") == 'sh'
    call setline(1,"#!/bin/bash")
    call setline(2,"#********************************************************************")
    call setline(3,"#Author: thomas")
    call setline(4,"#Date: ".strftime("%Y-%m-%d %H:%M"))
    call setline(5,"#E-mail: xxx@qq.com")
    call setline(6,"#FileName: ".expand("%"))
    call setline(7,"#Version: 1.0")
    call setline(8,"#Description:Shell Script")
    call setline(9,"#********************************************************************")
    call setline(10,"")
    endif
endfunc
autocmd BufNewFile * normal G
posted @ 2022-07-28 15:04  thomas-wu  阅读(146)  评论(0)    收藏  举报