如何用VIM快速书写Kubernetes配置清单

注:本文灵感来自shell中的快速书写shell脚本。实现了书写界面的清新明了,省去了文件头的反复重写,非常实用,话不多说:上脚本

脚本:

​[root@master ~]# vim ~/.vimrc 

set ignorecase
set cursorline
set autoindent
set ai
autocmd BufNewFile *.yaml exec ":call SetTitle()"

func SetTitle()
        if expand("%:e") == 'yaml'
        call setline(1,"#**************************************************************")
        call setline(2,"#Author:                     linkun")
        call setline(3,"#QQ:                         2********0")
        call setline(4,"#Date:                       ".strftime("%Y-%m-%d"))
        call setline(5,"#FileName:                   ".expand("%"))
        call setline(6,"#URL:                        https://blog.csdn.net/zisefeizhu")
        call setline(7,"#Description:                 The test script")                                                 
        call setline(8,"#Copyright (C):             ".strftime("%Y")." All rights reserved")
        call setline(9,"#************************************************************")
        call setline(10,"")
        endif
endfunc
autocmd BufNewFile * normal G
​

示例:

如何用VIM快速书写Kubernetes配置清单_第1张图片

 

你可能感兴趣的:(Kubernetes部分)