Vim

  1. 1. 编辑文件 /etc/vimrc

编辑文件 /etc/vimrc

1
2
3
4
5
6
7
8
9
10
11
12
autocmd BufNewFile *.py,*.sh,*, exec ":call SetTitle()"
let $author_name = "jeremy"
let $filetype_name = strpart(expand("%"), stridx(expand("%"), "."))
let $file_name = strpart(expand("%"), 0, stridx(expand("%"), "."))

func SetTitle()
if &filetype == 'sh'
call setline(1, "\#!/bin/bash")
call setline(2, "\# writen by: ".$author_name)
call setline(3, "\# file name: ".$file_name.$filetype_name)
endif
endfunc