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
    
  • 相关阅读:
    horizontal line and right way to code it in html, css
    Inline vs. block-level elements: a demonstration
    How wide is the default `<body>` margin?
    Getting wrong Version from Assembly using Reflection
    Where is the default size of a div element defined or calculated?
    Why padding is included in height sometimes?
    动态分析Android App之动态调试
    学习: Linux的 date 命令
    一个有趣的安全分析场景DSL设计
    Beats Elastic中的Auditbeat使用介绍
  • 原文地址:https://www.cnblogs.com/chenglee/p/10315528.html
Copyright © 2011-2022 走看看