I. Title: VIM Insert template automatically after new file
Ii. Summary
Both the Linux system administrator and the Linux development programmer often stop at the VI Editor programming development under the Linux environment. This article shares, the work of the practical programming tools skills, you can easily a key to the design of the desired template format.
Third, the demand
In the VI editor, the new encoding file is always blank, what method can be created, in advance to specify the corresponding template format it? How to save comments Ah, encoding format ah, update creation date Ah, and so on the note?
Iv. Realization OF
4.1 #vi ~/.VIMRC (no new-rw-r--r--)
4.2 Save it by depositing the following content
syntax onset nocompatible"Set numberfiletype onset history= +Set Background=Dark"Set Autoindent"Set SmartindentSet tabstop=4Set Shiftwidth=4Set Showmatchset guioptions-=tset rulerset nohlsset incsearch"Set Fileencodings=utf-8if&term=="xterm"Set T_co=8Set T_SB=^[[4%DM Set T_SF=^[[3%Dmendiffunctionaddfileinformation_php () let Infor="<?php\n" \."***************************************************************************\n" \."* \ n" \."* Copyright (c) \ n" \."* \ n" \."**************************************************************************/\ n" \."\ n" \."\ n" \."\ n" \."/** \ n" \."* @file:". Expand ("%")."\ n" \."* @author your name ([email protected]) \ n" \."* @date". Strftime ("%y-%m-%d%h:%m")."\ n" \."* @version 1.0 \ n" \."**/\ n" \."\ n" \."\ n" \."\ n" \."\ n" \."\ n" \."\ n" \."?>"Silent put! =Inforendfunctionautocmd Bufnewfile*. PHP call addfileinformation_php ()functionaddfileinformation_sh () let Infor="#!/bin/bash\n" \."\ n" \."# ***************************************************************************\n" \."# * \ n" \."# * @file:". Expand ("%")."\ n" \."# * @author: [email protected] \ n" \."# * @date:". Strftime ("%y-%m-%d%h:%m")."\ n" \."# * @version 1.0 \ n" \."# * @description: Shell script \ n" \."# * @Copyright (c) All right reserved \ n" \."#* \ n" \."#**************************************************************************/\ n" \."\ n" \."\ n" \."\ n" \."\ n" \."Exit 0"Silent put! =Inforendfunctionautocmd Bufnewfile*.SHCall addfileinformation_sh ()functionaddfileinformation_py () let Infor="#!/usr/bin/env python\n" \."#-*-Coding:utf-8-*-\n" \."# ************************************************************************ \ n" \."# * \ n" \."# * @file:". Expand ("%")."\ n" \."# * @author: [email protected] \ n" \."# * @date:". Strftime ("%y-%m-%d%h:%m")."\ n" \."# * @version 1.0 \ n" \."# * @description: Python Script \ n" \."# * @Copyright (c) All right reserved \ n" \."# * \ n" \."#************************************************************************* \ n" \."\ n" \."Import Os,sys" \."\ n" \."print u ' Chinese ' \ n" \."\ n" \."exit ()"Silent put! =Inforendfunctionautocmd Bufnewfile*.py Call Addfileinformation_py ()
V. Summary
Easy to fix, new PHP, Python, sh, etc. insert template format.
Good typesetting format, always can make readers pleasing, the definition of format, just a step away, gtd!
Vim Insert template automatically after new file