zoukankan      html  css  js  c++  java
  • vim自动补全头注释与说明

    做个笔记吧.

    .vimrc

    autocmd BufNewFile *.c,*.cpp,*.sh,*.py,*.java exec ":call SetTitle()"
    "定义函数SetTitle,自动插入文件头
    func SetTitle()
            "如果文件类型为.c或者.cpp文件
            if (&filetype == 'c' || &filetype == 'cpp')
                    call setline(1, "/*************************************************************************")
                    call setline(2, " @Author: chenglee")
                    call setline(3, " @Created Time : ".strftime("%c"))
                    call setline(4, " @File Name: ".expand("%"))
                    call setline(5, " @Description:")
                    call setline(6, " ************************************************************************/")
                    call setline(7,"")
            endif
            "如果文件类型为.sh文件
            if &filetype == 'sh'
                    call setline(1, "#*************************************************************************")
                    call setline(2, "#         > File Name: ".expand("%"))
                    call setline(3, "#         > Author: chenglee")
                    call setline(4, "#         > Main : chengkenlee@sina.com")
                    call setline(5, "#         > Blog : http://www.cnblogs.com/chenglee/")
                    call setline(6, "#         > Created Time : ".strftime("%c"))
                    call setline(7, "#*************************************************************************")
                    call setline(8, "#!/bin/bash")
                    call setline(9,"")
            endif
            "如果文件类型为.py文件
            if &filetype == 'python'
                    call setline(1, "#!/usr/bin/env python")
                    call setline(2, "# -*- coding=utf8 -*-")
                    call setline(3, """"")
                    call setline(4, "# Author: chenglee")
                    call setline(5, "# Created Time : ".strftime("%c"))
                    call setline(6, "# File Name: ".expand("%"))
                    call setline(7, "# Description:")
                    call setline(8, """"")
                    call setline(9,"")
            endif
            "如果文件类型为.java文件
            if &filetype == 'java'
                    call setline(1, "//coding=utf8")
                    call setline(2, "/**")
                    call setline(3, " * @Author: chenglee")
                    call setline(4, " * @Created Time : ".strftime("%c"))
                    call setline(5, " * @File Name: ".expand("%"))
                    call setline(6, " * @Description:")
                    call setline(7, " */")
                    call setline(8,"")
            endif
    endfunc
    " 自动将光标移动到文件末尾
    autocmd BufNewfile * normal G
    
  • 相关阅读:
    解决docker-compose: command not found
    idea 包存在提示不存在
    使用haproxy负载均衡
    docker使用阿里云仓库上传与下拉images
    docker使用官方仓库上传与下拉images
    WeaveScope-容器监控
    matlab打开
    硬盘测试
    matlab quiver()画箭头的函数
    SDK 和 API 的区别是什么?
  • 原文地址:https://www.cnblogs.com/chenglee/p/10315528.html
Copyright © 2011-2022 走看看