标签:
1 set nu "序号 2 set tabstop=4 "tab键的大小 3 set showcmd 4 nnoremap <F2> :set nonumber!<CR>:set foldcolumn=0<CR> "用F2开关数字,方便复制 5 6 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 7 "新建.c,.h,.sh,.java文件,自动插入文件头 8 autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" 9 ""定义函数SetTitle,自动插入文件头 10 func SetTitle() 11 "如果文件类型为.sh文件 12 if &filetype == ‘sh‘ 13 call setline(1,"\#########################################################################") 14 call append(line("."), "\# File Name: ".expand("%")) 15 call append(line(".")+1, "\#Copyright@ Author:Panhao_Neo ") "这里是版权名(作者) 16 call append(line(".")+2, "\# mail: panhao_neo@163.com") "邮箱 17 call append(line(".")+3, "\# Created Time: ".strftime("%c")) 18 call append(line(".")+4, "\#########################################################################") 19 call append(line(".")+5, "\#!/bin/bash") 20 call append(line(".")+6, "") 21 else 22 call setline(1, "/*************************************************************************") 23 call append(line("."), " > File Name: ".expand("%")) 24 call append(line(".")+1, " > Copyright@ Author:Panhao_Neo ") 25 call append(line(".")+2, " > Mail: panhao_neo@163.com ") 26 call append(line(".")+3, " > Created Time: ".strftime("%c")) 27 call append(line(".")+4, " ************************************************************************/") 28 call append(line(".")+5, "") 29 endif 30 if &filetype == ‘cpp‘ 31 call append(line(".")+6, "#include<iostream>") 32 call append(line(".")+7, "using namespace std;") 33 call append(line(".")+8, "") 34 endif 35 if &filetype == ‘c‘ 36 call append(line(".")+6, "#include<stdio.h>") 37 call append(line(".")+7, "int main()") 38 call append(line(".")+8, "{") 39 call append(line(".")+9, " ") 40 call append(line(".")+10, "}") 41 endif 42 " if &filetype == ‘java‘ 43 " call append(line(".")+6,"public class ".expand("%")) 44 " call append(line(".")+7,"") 45 " endif 46 "新建文件后,自动定位到文件末尾 47 autocmd BufNewFile * normal G 48 endfunc
标签:
原文地址:http://www.cnblogs.com/panhao/p/4557488.html