用Vim为Python源码自动添加#!行和编码行,,function Ins


function InsertPythonHeader()    let l1 = getline(1)    let l2 = getline(2)    if  match('\#!/', l1) == 0        exec 1        normal O        call setline(1,'#!/usr/bin/env python')    endif    if match("\#", l2) == 0 && (match("-", l2)  != 2 ¦¦ (match("code", l2) != 2))        exec 2        normal O        call setline(2,'#-*- coding:utf-8 -*-')    endifendfunctionau FileType python call InsertPythonHeader()

评论关闭