The VIM editor adds default author information

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.