vim /etc/vim/vimrc
map <F4> ms:call TitleDet()<cr>‘s function AddTitle() call append(0,"#!/bin/bash") call append(1,"##############################################") call append(2,"#Author: hanye") call append(3,"#Email: [email protected]") call append(4,"#Last modified: ".strftime("%Y/%m/%d/%H:%M")) call append(5,"#Filename: ".expand("%:t")) call append(6,"#Revision: 0.1") call append(7,"#Description: ") call append(8,"#crontab: * * * * * ".expand("%:t")) call append(9,"#Website: www.hanye") call append(10,"#License: GPL") call append(11,"##############################################") echohl WarningMsg | echo "Successful in adding the copyright." | echohl None endfunction function UpdateTitle() normal m‘ execute ‘/#*Last modified:/[email protected]:.*[email protected]\=strftime(":%Y-%m-%d %H:%M")@‘ normal ‘‘ normal mk execute ‘/#*Filename:/[email protected]:.*[email protected]\=":".expand("%:t")@‘ execute "noh" normal ‘k echohl WarningMsg | echo "Successful in updating the copy right." | echohl None endfunction function TitleDet() let n=1 while n < 7 let line = getline(n) if line =~ ‘^\#\s*\S*Last\smodified:\S*.*$‘ call UpdateTitle() return endif let n = n + 1 endwhile call AddTitle() endfunction
测试 vim a.txt
fn + f4/f4 实现一键插入编辑信息
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。