Many programmers want to add some information about the author's information to their own programs, so how should we implement this requirement?
As an example of a shell script, just modify the/ETC/VIMRC configuration file and add the following to the end of the file
Note: In the VIMRC file, the comment line is "tagged, copy the following content need to change # ", otherwise it will be an error
#为F4按键添加作者信息, if you need to add a python you can add F5map <f4> ms:call titledet () <cr> ' sfunction AddTitle () call append (0, "#!/bin/bash") call append (1, "##############################################") call append (2, "#Author: Liuzhengwei - [email protected] call append (3, "#QQ: 1135960569") call append (4, "#Last modified: ". Strftime ("%y-%m-%d %h:%m")) call append (5, "#Filename: ". Expand ("%:t")) call append (6, "#Description: ") call append (7, "######################################### ##### ") echohl WarningMsg | echo " successful in adding the copyright. " | echohl noneendfunction# modifying file modification time and filename 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 noneendfunction# judgment if there is a last modified in the first 10 rows: The field # if not, then the information such as the author has not been added, then re-add # if there is , then only update the modified time and file name 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
Once added, open a test.sh file and press F4 to see the following information.
[Email protected] tmp]# vim test.sh#!/bin/bash############################################## #Author: Liuzhengwei-[ Email protected] #QQ: 1135960569#last modified:2016-07-04 15:55#filename:test.sh#description: ###################### ########################
This article is from the "burning Years of Passion" blog, please be sure to keep this source http://liuzhengwei521.blog.51cto.com/4855442/1883945
The VIM editor adds default author information