可怕的北京站不仅仅队伍强 还有i7 16G的电脑……
而且电脑里没有codeblocksT_T
所以只能强行学一波vim……
直接复制代码 然后把文件名改成_vimrc就好了~
(从学校机房直接扒的代码 好像和kuangbin大神的差不多……)
1 set nocompatible 2 source $VIMRUNTIME/vimrc_example.vim 3 source $VIMRUNTIME/mswin.vim 4 behave mswin 5 cd D:c++ 6 7 set diffexpr=MyDiff() 8 function MyDiff() 9 let opt = '-a --binary ' 10 if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif 11 if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif 12 let arg1 = v:fname_in 13 if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif 14 let arg2 = v:fname_new 15 if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif 16 let arg3 = v:fname_out 17 if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif 18 let eq = '' 19 if $VIMRUNTIME =~ ' ' 20 if &sh =~ '<cmd' 21 let cmd = '""' . $VIMRUNTIME . 'diff"' 22 let eq = '"' 23 else 24 let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . 'diff"' 25 endif 26 else 27 let cmd = $VIMRUNTIME . 'diff' 28 endif 29 silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq 30 endfunction 31 32 "set gfn=Fixedsys:h16 33 34 set number " 显示行号 35 set cursorline " 突出显示当前行 36 set tabstop=4 " 设置tab键的宽度 37 "set backspace=2 " 设置退格键可用 38 syn on " 打开语法高亮 39 set guifont=Courier_New:h14:cANSI "设置字体和大小 40 41 colorscheme koehler " 设置主题方案 42 "hi Normal guifg=white guibg=#300622 "设置背景颜色 43 "set showmatch " 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号 44 set smartindent " 智能对齐方式 45 set shiftwidth=4 " 换行时行间交错使用4个空格 46 set autoindent " 自动对齐 47 set ai! " 设置自动缩进 48 49 " 自动检测文件类型 50 filetype on 51 filetype plugin on 52 53 filetype plugin indent on " 开启插件 54 set completeopt=longest,menu 55 au GUIEnter * simalt ~x "打开Gvim时自动最大化 56 57 if has("win32") 58 59 " vim在与屏幕/键盘交互时用的编码 60 "set termencoding = 61 62 " 打开文件时用的编码 63 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 64 65 " 文件存储时的编码 66 " set fileencoding = 67 68 set lines=30 69 set columns=120 70 71 " 显示行号 72 set nu 73 74 " 不换行 75 "set nowrap 76 77 " 状态栏不自动消失 78 set laststatus=2 79 80 " 设置缩进 81 set shiftwidth=4 82 set tabstop=4 83 84 " 关闭备份 85 set nobackup 86 set nowritebackup 87 88 " 移除菜单栏、工具栏和滚动条 89 "set guioptions-=m 90 "set guioptions-=T 91 "set guioptions-=r 92 "set guioptions-=b 93 94 " 代码折叠 95 "set foldmethod=syntax 96 97 " 使用中文帮助 98 set helplang=cn 99 100 " gvim设置 101 if has("gui_running") 102 103 " vim内部编码 104 set encoding=utf-8 105 106 " 解决起始画面及标题乱码 107 language messages zh_CN.utf-8 108 109 " 解决菜单乱码 110 source $VIMRUNTIME/delmenu.vim 111 source $VIMRUNTIME/menu.vim 112 113 " 字体设置 114 "set guifont=Menlo:h14 115 "set guifont=Monaco:h9 116 "set guifont=Consolas:h10 117 "set guifont=Courier_New:h10 118 "set guifontwide=微软雅黑:h14 119 120 " 设置窗口的起始位置和大小 121 winpos 250 200 122 123 endif 124 125 "vimwiki存储路径 126 let g:vimwiki_use_mouse = 1 127 let g:vimwiki_list = [{ 128 "path":$VIMRUNTIME."/vimwiki", 129 "path_html":$VIMRUNTIME."/vimwiki/html", 130 "html_header":$VIMRUNTIME."/vimwiki/html_template/header.tpl", 131 "html_footer":$VIMRUNTIME."/vimwiki/html_template/footer.tpl" 132 }] 133 134 endif 135 136 137 " 快捷键 138 " F2取消高亮 139 140 nmap <F2> :nohlsearch<CR> 141 142 " F3删掉windows换行符^M 143 144 nmap <F3> :%s/ ( )/1/g<CR> 145 146 147 " ========================================================================== 148 " Shift + r 切换Vim是否总在最前面显示 149 " ========================================================================== 150 if has('gui_running') && has('gui_win32') && has('libcall') 151 let g:MyVimLib = 'gvimfullscreen.dll' 152 153 154 155 let g:isfull = 0 156 function! ToggleFullScreen() 157 "let s:IsFullScreen = libcallnr("gvimfullscreen.dll", 'ToggleFullScreen', 0) 158 "let s:IsFullScreen = libcallnr("gvimfullscreen.dll", 'ToggleFullScreen', 27 + 29*256 + 30*256*256) 159 "call libcall(g:MyVimLib, 'ToggleFullScreen', 27 + 29*256 + 30*256*256) 160 161 if g:isfull == 0 162 call libcall(g:MyVimLib, 'ToggleFullScreen', 40 + 10*256 + 30*256*256) "红 绿 蓝 (可以用画图找颜色) 163 set guioptions-=m "Remove menubar 164 set guioptions-=T "Remove toolbar 165 set guioptions-=r "Remove v_scroll bar 166 let g:isfull = 1 167 else 168 call libcall(g:MyVimLib, 'ToggleFullScreen', 240 + 240*256 + 240*256*256) 169 set guioptions+=m "Show menubar 170 set guioptions+=T "Show toolbar 171 set guioptions+=r "Show v_scroll bar 172 let g:isfull = 0 173 endif 174 endfunction 175 176 let g:VimAlpha = 220 177 function! SetAlpha(alpha) 178 let g:VimAlpha = g:VimAlpha + a:alpha 179 if g:VimAlpha < 180 180 let g:VimAlpha = 180 181 endif 182 if g:VimAlpha > 255 183 let g:VimAlpha = 255 184 endif 185 call libcall(g:MyVimLib, 'SetAlpha', g:VimAlpha) 186 endfunction 187 188 let g:VimTopMost = 0 189 function! SwitchVimTopMostMode() 190 if g:VimTopMost == 0 191 let g:VimTopMost = 1 192 else 193 let g:VimTopMost = 0 194 endif 195 call libcall(g:MyVimLib, 'EnableTopMost', g:VimTopMost) 196 endfunction 197 "映射 F11 切换全屏vim 198 imap <F11> <esc>:call ToggleFullScreen()<cr> 199 nmap <F11> :call ToggleFullScreen()<cr> 200 "切换Vim是否在最前面显示 201 nmap <F12> :call SwitchVimTopMostMode()<cr> 202 imap <F12> <esc>:call SwitchVimTopMostMode()<cr> 203 "增加Vim窗体的不透明度 204 "nmap <s-t> <esc>:call SetAlpha(10)<cr> 205 "增加Vim窗体的透明度 206 "nmap <s-y> <esc>:call SetAlpha(-10)<cr> 207 "Vim启动的时候自动调用InitVim 以去除Vim的白色边框 208 autocmd GUIEnter * call libcallnr(g:MyVimLib, 'InitVim', 0) 209 " 默认设置透明 210 autocmd GUIEnter * call libcallnr(g:MyVimLib, 'SetAlpha', g:VimAlpha) 211 endif 212 " }}} 213 214 "------------------------------------------------------------------------------ 215 " < 判断操作系统是否是 Windows 还是 Linux > 216 "------------------------------------------------------------------------------ 217 if(has("win32") || has("win64") || has("win95") || has("win16")) 218 let g:iswindows = 1 219 else 220 let g:iswindows = 0 221 endif 222 223 "------------------------------------------------------------------------------ 224 " < 判断是终端还是 Gvim > 225 "------------------------------------------------------------------------------ 226 if has("gui_running") 227 let g:isGUI = 1 228 else 229 let g:isGUI = 0 230 endif 231 232 "------------------------------------------------------------------------------ 233 " < 编译、连接、运行配置 > 234 "------------------------------------------------------------------------------ 235 " F9 一键保存、编译、连接存并运行 236 237 map <F5> :w<CR>:!javac % && java %<<CR> 238 imap <F5> <ESC>:w<CR>:!javac % && java %<<CR> 239 240 map <F9> :call Run()<CR> 241 imap <F9> <ESC>:call Run()<CR> 242 243 map <S-F10> :tabnew %<.in<CR>DG<C-V>:wq<CR>:echo "Copying Successful"<CR> 244 map <C-F10> :tabnew %<.in<CR> 245 map <F10> <ESC>:w<CR>:call RunWithFile()<CR> 246 imap <F10> <ESC>:w<CR>:call RunWithFile()<CR> 247 248 " Ctrl + F9 一键保存并编译 249 map <c-F9> :call Compile()<CR> 250 imap <c-F9> <ESC>:call Compile()<CR> 251 252 " Ctrl + F10 一键保存并连接 253 "map <c-F10> :call Link()<CR> 254 "imap <c-F10> <ESC>:call Link()<CR> 255 256 let s:LastShellReturn_C = 0 257 let s:LastShellReturn_L = 0 258 let s:ShowWarning = 1 259 let s:Obj_Extension = '.o' 260 let s:Exe_Extension = '.exe' 261 let s:Sou_Error = 0 262 263 let s:windows_CFlags = 'gcc -fexec-charset=gbk -Wall -g -O0 -c % -o %<.o' 264 let s:linux_CFlags = 'gcc -Wall -g -O0 -c % -o %<.o' 265 266 let s:windows_CPPFlags = 'g++ -fexec-charset=gbk -Wall -g -O0 -c % -o %<.o' 267 let s:linux_CPPFlags = 'g++ -Wall -g -O0 -c % -o %<.o' 268 269 func! Compile() 270 exe ":ccl" 271 exe ":update" 272 if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx" 273 let s:Sou_Error = 0 274 let s:LastShellReturn_C = 0 275 let Sou = expand("%:p") 276 let Obj = expand("%:p:r").s:Obj_Extension 277 let Obj_Name = expand("%:p:t:r").s:Obj_Extension 278 let v:statusmsg = '' 279 if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou))) 280 redraw! 281 if expand("%:e") == "c" 282 if g:iswindows 283 exe ":setlocal makeprg=".s:windows_CFlags 284 else 285 exe ":setlocal makeprg=".s:linux_CFlags 286 endif 287 echohl WarningMsg | echo " compiling..." 288 silent make 289 elseif expand("%:e") == "cpp" || expand("%:e") == "cxx" 290 if g:iswindows 291 exe ":setlocal makeprg=".s:windows_CPPFlags 292 else 293 exe ":setlocal makeprg=".s:linux_CPPFlags 294 endif 295 echohl WarningMsg | echo " compiling..." 296 silent make 297 endif 298 redraw! 299 if v:shell_error != 0 300 let s:LastShellReturn_C = v:shell_error 301 endif 302 if g:iswindows 303 if s:LastShellReturn_C != 0 304 exe ":bo cope" 305 echohl WarningMsg | echo " compilation failed" 306 else 307 if s:ShowWarning 308 exe ":bo cw" 309 endif 310 echohl WarningMsg | echo " compilation successful" 311 endif 312 else 313 if empty(v:statusmsg) 314 echohl WarningMsg | echo " compilation successful" 315 else 316 exe ":bo cope" 317 endif 318 endif 319 else 320 echohl WarningMsg | echo ""Obj_Name"is up to date" 321 endif 322 else 323 let s:Sou_Error = 1 324 echohl WarningMsg | echo " please choose the correct source file" 325 endif 326 exe ":setlocal makeprg=make" 327 endfunc 328 329 func! Link() 330 call Compile() 331 if s:Sou_Error || s:LastShellReturn_C != 0 332 return 333 endif 334 let s:LastShellReturn_L = 0 335 let Sou = expand("%:p") 336 let Obj = expand("%:p:r").s:Obj_Extension 337 if g:iswindows 338 let Exe = expand("%:p:r").s:Exe_Extension 339 let Exe_Name = expand("%:p:t:r").s:Exe_Extension 340 else 341 let Exe = expand("%:p:r") 342 let Exe_Name = expand("%:p:t:r") 343 endif 344 let v:statusmsg = '' 345 if filereadable(Obj) && (getftime(Obj) >= getftime(Sou)) 346 redraw! 347 if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj)) 348 if expand("%:e") == "c" 349 setlocal makeprg=gcc -o %< %<.o 350 echohl WarningMsg | echo " linking..." 351 silent make 352 elseif expand("%:e") == "cpp" || expand("%:e") == "cxx" 353 setlocal makeprg=g++ -o %< %<.o 354 echohl WarningMsg | echo " linking..." 355 silent make 356 endif 357 redraw! 358 if v:shell_error != 0 359 let s:LastShellReturn_L = v:shell_error 360 endif 361 if g:iswindows 362 if s:LastShellReturn_L != 0 363 exe ":bo cope" 364 echohl WarningMsg | echo " linking failed" 365 else 366 if s:ShowWarning 367 exe ":bo cw" 368 endif 369 echohl WarningMsg | echo " linking successful" 370 endif 371 else 372 if empty(v:statusmsg) 373 echohl WarningMsg | echo " linking successful" 374 else 375 exe ":bo cope" 376 endif 377 endif 378 else 379 echohl WarningMsg | echo ""Exe_Name"is up to date" 380 endif 381 endif 382 setlocal makeprg=make 383 endfunc 384 385 func! Run() 386 let s:ShowWarning = 0 387 call Link() 388 let s:ShowWarning = 1 389 if s:Sou_Error || s:LastShellReturn_C != 0 || s:LastShellReturn_L != 0 390 return 391 endif 392 let Sou = expand("%:p") 393 let Obj = expand("%:p:r").s:Obj_Extension 394 if g:iswindows 395 let Exe = expand("%:p:r").s:Exe_Extension 396 else 397 let Exe = expand("%:p:r") 398 endif 399 if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou) 400 redraw! 401 echohl WarningMsg | echo " running..." 402 if g:iswindows 403 exe ":!%<.exe" 404 else 405 if g:isGUI 406 exe ":!gnome-terminal -e ./%<" 407 else 408 exe ":!./%<" 409 endif 410 endif 411 redraw! 412 echohl WarningMsg | echo " running finish" 413 endif 414 endfunc 415 416 func! RunWithFile() 417 let s:ShowWarning = 0 418 call Link() 419 exe ":!%<.exe < %<.in" 420 endfunc 421 422 "set nu 423 "set history=1000000 424 "set tabstop=4 425 "set shiftwidth=4 426 427 "set smarttab 428 429 430 "set cindent 431 432 "colo evening 433 434 set showcmd 435 436 set nobackup 437 set noswapfile 438 439 set mouse=a 440 441 442 map <F6> :call CR()<CR> 443 func! CR() 444 exec "w" 445 exec "!g++ -O2 -g % -o %<" 446 exec "! %<" 447 endfunc 448 449 imap <c-]> {<cr>}<c-o>O<left><right> 450 451 map <C-A> ggVG"+y 452 453 454 "inoremap ( ()<LEFT> 455 "inoremap [ []<LEFT> 456 "inoremap { {}<LEFT> 457 "inoremap " ""<LEFT> 458 "inoremap ' ''<LEFT> 459 460 inoremap ( ()<ESC>i 461 inoremap [ []<ESC>i 462 inoremap { {}<ESC>i 463 inoremap " ""<ESC>i 464 inoremap ' ''<ESC>i 465 466 467 map <F2> :call SetTitle()<CR> 468 func SetTitle() 469 let l = 0 470 let l = l + 1 | call setline(l,'/* ***********************************************') 471 let l = l + 1 | call setline(l,'Author :Sun Yuefeng') 472 let l = l + 1 | call setline(l,'Created Time :'.strftime('%c')) 473 let l = l + 1 | call setline(l,'File Name :'.expand('%')) 474 let l = l + 1 | call setline(l,'************************************************ */') 475 let l = l + 1 | call setline(l,'') 476 477 let l = l + 1 | call setline(l,'#include<cstdio>') 478 let l = l + 1 | call setline(l,'#include<iostream>') 479 let l = l + 1 | call setline(l,'#include<algorithm>') 480 let l = l + 1 | call setline(l,'#include<cmath>') 481 let l = l + 1 | call setline(l,'#include<cstring>') 482 let l = l + 1 | call setline(l,'#include<string>') 483 let l = l + 1 | call setline(l,'#include<bitset>') 484 let l = l + 1 | call setline(l,'#include<map>') 485 let l = l + 1 | call setline(l,'#include<set>') 486 let l = l + 1 | call setline(l,'#include<stack>') 487 let l = l + 1 | call setline(l,'#include<vector>') 488 let l = l + 1 | call setline(l,'#include<queue>') 489 let l = l + 1 | call setline(l,'#include<list>') 490 let l = l + 1 | call setline(l,'#define M(a,b) memset(a,b,sizeof(a))') 491 let l = l + 1 | call setline(l,'using namespace std;') 492 let l = l + 1 | call setline(l,'typedef long long ll;') 493 let l = l + 1 | call setline(l,'const int inf=0x3f3f3f3f;') 494 let l = l + 1 | call setline(l,'const int maxn=1e9+10;') 495 let l = l + 1 | call setline(l,'const int mod=1e7+7;') 496 let l = l + 1 | call setline(l,'int dx[8]= {0,0,1,-1,1,-1,1,-1};') 497 let l = l + 1 | call setline(l,'int dy[8]= {1,-1,0,0,-1,1,1,-1};') 498 499 let l = l + 1 | call setline(l,'') 500 let l = l + 1 | call setline(l,'int main()') 501 let l = l + 1 | call setline(l,'{') 502 let l = l + 1 | call setline(l,' //freopen("in.txt","r",stdin);') 503 let l = l + 1 | call setline(l,' //freopen("out.txt","w",stdout);') 504 let l = l + 1 | call setline(l,' ') 505 let l = l + 1 | call setline(l,' return 0;') 506 let l = l + 1 | call setline(l,'}') 507 endfunc