zoukankan      html  css  js  c++  java
  • vimrc配置-新建文件时自动生成文件头

    vimrc配置-新建文件时自动生成文件头

     
     auto add file header
    autocmd BufNewFile *.py 0r /home/zxkletters/.vim/vim_template/vim_header_for_python
    autocmd BufNewFile *.py ks|call FileName()|'s
    autocmd BufNewFile *.py ks|call CreatedTime()|'s
     
    autocmd BufNewFile *.sh 0r /home/zxkletters/.vim/vim_template/vim_header_for_sh
    autocmd BufNewFile *.sh ks|call FileName()|'s
    autocmd BufNewFile *.sh ks|call CreatedTime()|'s
     
    fun FileName()
    if line("$") > 10
    let l = 10
    else
    let l = line("$")
    endif
    exe "1," . l . "g/File Name:.*/s/File Name:.*/File Name: " .expand("%")
    endfun
     
    fun CreatedTime()
    if line("$") > 10
    let l = 10
    else
    let l = line("$")
    endif
    exe "1," . l . "g/Created Time:.*/s/Created Time:.*/Created Time: " .strftime("%Y-%m-%d %T")
    endfun
    " end auto add file header
     

    /home/zxkletters/.vim/vim_template/vim_header_for_python文件内容:

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    #########################################################################
    # File Name:
    # Author: zxkletters
    # mail: zxkletters@gmail.com
    # Created Time:
    #########################################################################
    

    /home/zxkletters/.vim/vim_template/vim_header_for_sh文件内容:

    #########################################################################
    # File Name:
    # Author: zxkletters
    # mail: zxkletters@gmail.com
    # Created Time:
    #########################################################################
    #!/bin/bash
  • 相关阅读:
    数值分析实验之数值积分法(java 代码)
    Python 数据处理
    Python 网络爬虫
    数据库系统开发——旅游公司机票查询及预订系统
    Python词云生成
    Python库的安装与查看
    Python词频统计
    Python程序设计训练
    Python编程基础训练
    如何在同一Linux服务器上创建多站点
  • 原文地址:https://www.cnblogs.com/zjgtan/p/3414865.html
Copyright © 2011-2022 走看看