vim .vimrc


set tabstop=4
set number
set cul 
set cuc 
hi CursorColumn ctermfg=3 ctermbg=2
function InsertPythonComment()
    exe 'normal'.1.'G'
    let line = getline('.')
    if line =~ '^#!.*$' || line =~ '^#.*coding:.*$'
        return
    endif
    normal O
    call setline('.', '#!/usr/bin/env python')
    normal o
    call setline('.', '# -*- coding:utf-8 -*-')
    normal o
    call setline('.', ' ')
    normal o
    call setline('.', '# Author : '.g:python_author)
    normal o
    call setline('.', '# E-mail : '.g:python_email)                                                                                                                                                     
    normal o
    call setline('.', '# Date   : '.strftime("%y/%m/%d %H:%M:%S"))
    normal o
    call setline('.', '# Desc   : ')
    normal o
    call setline('.', ' ')
    normal o
    call cursor(7, 17) 
endfunction
function InsertCommentWhenOpen()
    if a:lastline == 1 && !getline('.')
        call InsertPythonComment()
    end 
endfunc
au FileType python :%call InsertCommentWhenOpen()

        
let g:python_author = 'zhibo.wang'
let g:python_email  = 'gm.zhibo.wang@gmail.com'
原文地址:https://www.cnblogs.com/dockers/p/7513036.html