在用户的家目录,创建新文件.vimrc,加入以下内容。
这样我们以后再次打开以 .sh结尾的文件时就会成自动生成一些注释信息。
[root@localhost ~]# cd ~ [root@localhost ~]# pwd /root [root@localhost ~]# vim .vimrc set ignorecase set cursorline set autoindent autocmd BufNewFile *.sh exec ":call SetTitle()" func SetTitle() if expand("%:e") == 'sh' call setline(1,"#!/bin/bash") call setline(2,"#****************************************************") call setline(3,"#Date: ".strftime("%Y-%m-%d")) call setline(4,"#Author: Damon Ye") call setline(5,"#FileName: ".expand("%")) call setline(6,"#Description:The test script") call setline(7,"#****************************************************") call setline(8,"") endif endfunc autocmd BufNewFile * normal G 按ESC,再按ZZ保存并退出