标签:日常总结
参考地址:https://github.com/ma6174/vim
vim /etc/vimrc
" 下面是添加F4热键自动加入文件头注释信息
map <F4> ms:call AddAuthor()<cr>‘S
function AddAuthor()
let n=1
while n < 11
let line = getline(n)
if line=~‘[#]*\s*\*\s*\S*Last\s*modified\s*:\s*\S*.*$‘
call UpdateTitle()
return
endif
let n = n + 1
endwhile
if &filetype == ‘sh‘
call AddTitleForShell()
elseif &filetype == ‘python‘
call AddTitleForPython()
else
call AddTitleForC()
endif
endfunction
"" add comment for Python
function AddTitleForPython()
call append(0,"#!/usr/bin/env python")
call append(1,"#coding:utf-8")
call append(2,"")
call append(3,"# **********************************************************")
call append(4,"# * Author : fujinzhou")
call append(5,"# * Email : 1445675350@qq.com")
call append(6,"# * Create time : ".strftime("%Y-%m-%d %H:%M"))
call append(7,"# * Last modified : ".strftime("%Y-%m-%d %H:%M"))
call append(8,"# * Filename : ".expand("%:t"))
call append(9,"# * Description : ")
call append(10,"# **********************************************************")
echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endfunction
"" add conment for shell
function AddTitleForShell()
call append(0,"#!/bin/bash")
call append(1,"# **********************************************************")
call append(2,"# * Author : fujinzhou")
call append(3,"# * Email : 1445675350@qq.com")
call append(4,"# * Create time : ".strftime("%Y-%m-%d %H:%M"))
call append(5,"# * Last modified : ".strftime("%Y-%m-%d %H:%M"))
call append(6,"# * Filename : ".expand("%:t"))
call append(7,"# * Description : ")
call append(8,"# **********************************************************")
endfunction本文出自 “不抛弃!不放弃” 博客,请务必保留此出处http://thedream.blog.51cto.com/6427769/1873060
标签:日常总结
原文地址:http://thedream.blog.51cto.com/6427769/1873060