美文网首页
Vim配置-新建python自动添加注释

Vim配置-新建python自动添加注释

作者: lusenoot | 来源:发表于2017-08-18 16:33 被阅读0次

Vim新建python,自动添加注释头信息

function GetSystemUname()
    let uname=system("whoami")
    if uname[strlen(uname) - 1] == "\n"
        let uname=strpart(uname, 0, strlen(uname) - 1)
    endif
    return uname
endf

function HeaderPython()
    let username=GetSystemUname()
    let filename=expand('%:t')
    call setline(1, "# -*- coding: utf-8 -*-")
    call setline(2, "# Author @".username)
    call setline(3, "# Description @ ".filename)
    call setline(4, "#  CreateTime @ ".strftime('%Y-%m-%d %H:%M:%S', localtime()))
    normal G
    normal o
    normal o
endf

autocmd BufNewFile *.py call HeaderPython()

相关文章

网友评论

      本文标题:Vim配置-新建python自动添加注释

      本文链接:https://www.haomeiwen.com/subject/edparxtx.html