forked from ruanyl/bigvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc.local.example
More file actions
66 lines (66 loc) · 3.68 KB
/
vimrc.local.example
File metadata and controls
66 lines (66 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
" in order to make your local setting works
" copy this file and rename it as vimrc.local
" add your vimrc configurations here
" 新建.c,.h,.sh,.java文件,自动插入文件头 {
autocmd BufNewFile *.md exec ":call Setmd()"
func Setmd()
call setline(1,"date: ".strftime("%Y-%m-%d %T"))
call append(line("."),"tags: ")
call append(line(".")+1,"---")
call append(line(".")+2,"")
endfunc
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.py,*.html,*.php,*java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
if &filetype=='python'
call setline(1, "#-*- encoding: UTF-8 -*-")
call append(line("."), "#---------------------------------import------------------------------------")
call append(line(".")+1, "#---------------------------------------------------------------------------")
call append(line(".")+2, "############################################################################")
endif
if &filetype=='sh'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: hoowhen")
call append(line(".")+2, "\# mail: hoowhen@126.com")
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\# Last changed: TIMESTAMP")
call append(line(".")+5, "\#########################################################################")
call append(line(".")+6, "\#!/bin/bash".expand("%"))
call append(line(".")+7, "")
endif
if &filetype=='html' || &filetype=='php'
call setline(1, "<!--*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: hoowhen")
call append(line(".")+2, " > Mail: hoowhen@126.com")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " > Last changed: TIMESTAMP")
call append(line(".")+5, " ************************************************************************-->")
call append(line(".")+6, "")
endif
if &filetype=='cpp'
call append(line(".")+6, "#include<iostream>")
call append(line(".")+7, "using namespace std;")
call append(line(".")+8, "")
endif
if &filetype=='c'
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: hoowhen")
call append(line(".")+2, " > Mail: hoowhen@126.com")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " > Last changed: TIMESTAMP")
call append(line(".")+5, " ************************************************************************/")
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+7, "")
endif
if &filetype=='php' || &filetype=='html'
call setline(9,['<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">','<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">','<head>',' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />',' <title></title>','</head>','<body>','</body>','</html>'])
endif
if &filetype=='java'
call setline(9,['public class '.strpart(expand("%"),0,strlen(expand("%"))-5),'{','}'])
endif
endfunc
autocmd BufNewFile * normal G "新建文件后,自动定位到文件末尾
" }