How do shell scripts automatically generate comments at the beginning of a file
Today I'll show you how the shell script automatically generates comments at the beginning of the file. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.
When we write bash scripts, we need to write comments in shell. It is very troublesome to write notes manually every time. This article will share with you how to automatically generate comments and introductions in the file.
Let's share a template file of the shell script. Copy it to the user's home directory / root/ and name it .vimrc, so that some comments will be generated automatically when you open the .sh file later. You only need to modify it slightly:
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, "# Author: XT_TALK") call setline (4 "# Date:" .strftime ("% Y-%m-%d") call setline (5, "# FileName:" .call setline ("%")) call setline (6 "# *") call setline (7 "") endif endfunc autocmd BufNewFile * normal G and above are all about how the shell script automatically generates comments at the beginning of the file For more information about how the shell script automatically generates comments at the beginning of the file, you can search for previous articles or browse the following articles to learn! I believe the editor will add more knowledge to you. I hope you can support it!