acm菜鸡必备 1 runtime! debian.vim 2 if has("syntax") 3 syntax on 4 endif 5 if filereadable("/etc/vim/vimrc.local") 6 source /etc/vim/vimrc.local 7 endif 8 "syntax high light 9 syntax on 10 "show the line number 11 set nu 12 "为c程序提供自动缩进 13 set smartindent 14 "使用c程序的自动缩进 15 set cindent 16 "设置缩进的空格数为4 17 set shiftwidth=4 18 "设置制表符 19 set tabstop=4 20 set softtabstop=4 21 "匹配模式() 22 set showmatch 23 "不保留备份文件 24 set nobackup 25 "配色方案 26 colorscheme slate 27 "中文显示 28 set fileencodings=utf-8,gb2312,gbk,gb18030 29 set termencoding=utf-8 30 set encoding=prc 31 "字体 32 "自动插入头文件 33 autocmd BufNewFile *.cpp exec ":call SetTitle()" 34 func SetTitle() 35 if &filetype =='cpp' 36 call setline(1,"// file name: ".expand("%")." //") 37 call append(line("."),"// author: huangjipeng //") 38 call append(line(".")+1,"// creat time: ".strftime("%c")." //") 39 call append(line(".")+2,"///////////////////////////////////////////////////////") 40 call append(line(".")+3,"#include<iostream>") 41 call append(line(".")+4,"#include<cstdio>") 42 call append(line(".")+5,"#include<cstdlib>") 43 call append(line(".")+6,"#include<string.h>") 44 call append(line(".")+7,"#include<math.h>") 45 call append(line(".")+8,"#include<algorithm>") 46 call append(line(".")+9,"#include<map>") 47 call append(line(".")+10,"#include<vector>") 48 call append(line(".")+11,"#include<queue>") 49 call append(line(".")+12,"using namespace std;") 50 call append(line(".")+13,"#define MAXN 1") 51 call append(line(".")+14,"int main()") 52 call append(line(".")+15,"{") 53 call append(line(".")+16," return 0;") 54 call append(line(".")+17,"}") 55 endif 56 "新建文件时定位到文件尾 57 autocmd BufNewFile * normal G 58 endfunc 59 map <F9> :call CompileCpp()<CR> 60 function CompileCpp() 61 set makeprg=g++\ -o\ %<\ % 62 silent make 63 let myfile=expand("%:r") 64 if filereadable(myfile) 65 execute "! ./%< && rm ./%<" 66 else 67 cope5 68 endif 69 endfunction
个人vim配置文件
时间: 2024-11-05 23:34:26