標籤:
把vim當主力編輯器搞acm很長一段時間了,用vim的好處不必多說,
在此總結一下ACM中的vim配置方法,配置直接寫到 ~/.vimrc 中就可以了.
比賽用的14行配置:
syntax onset cindentset nuset tabstop=4set shiftwidth=4set background=darkmap <C-A> ggVG"+ymap <F5> :call Run()<CR>func! Run()exec "w"exec "!g++ -Wall % -o %<"exec "!./%<"endfunc
日常用的配置 :
主要多了運行java,一鍵補全標頭檔,字型什麼的
syntax onset cindentset mouse=aset tabstop=4set shiftwidth=4set nuset nocompatibleset showmodeset showcmdset ignorecase smartcaseset hlsearchset autoindentset smarttabset smartindent"colorscheme solarizedset background=darkset gfn=Source\ Code\ Pro\ 14map <F5> :call Run()<CR>func! Run() exec "w"if &filetype is 'cpp'|| &filetype is 'c' || &filetype is 'cc' exec "!clang++ -Wall % -o %<" exec "!./%<"elseif &filetype is 'java'exec "!javac\ -d\ .\ %"exec "!java\ %<"endifendfuncmap <C-A> ggVG"+ymap <F12> :call SetTitle()<CR>func SetTitle()let l = 0let l = l + 1 | call setline(l,'/* ***********************************************')let l = l + 1 | call setline(l,'Author :CKboss')let l = l + 1 | call setline(l,'Created Time :'.strftime('%c'))let l = l + 1 | call setline(l,'File Name :'.expand('%'))let l = l + 1 | call setline(l,'************************************************ */')let l = l + 1 | call setline(l,'')let l = l + 1 | call setline(l,'#include <iostream>')let l = l + 1 | call setline(l,'#include <cstdio>')let l = l + 1 | call setline(l,'#include <cstring>')let l = l + 1 | call setline(l,'#include <algorithm>')let l = l + 1 | call setline(l,'#include <string>')let l = l + 1 | call setline(l,'#include <cmath>')let l = l + 1 | call setline(l,'#include <cstdlib>')let l = l + 1 | call setline(l,'#include <vector>')let l = l + 1 | call setline(l,'#include <queue>')let l = l + 1 | call setline(l,'#include <set>')let l = l + 1 | call setline(l,'#include <map>')let l = l + 1 | call setline(l,'')let l = l + 1 | call setline(l,'using namespace std;')let l = l + 1 | call setline(l,'')let l = l + 1 | call setline(l,'int main()')let l = l + 1 | call setline(l,'{')let l = l + 1 | call setline(l,'//freopen("in.txt","r",stdin);')let l = l + 1 | call setline(l,'//freopen("out.txt","w",stdout);')let l = l + 1 | call setline(l,' ')let l = l + 1 | call setline(l,' return 0;')let l = l + 1 | call setline(l,'}')endfunc
linux系統中用vim寫acm代碼的說明:
(注:在終端中使用以獲得最佳效果)
1.開啟終端 mkdir 建立檔案夾 , touch 建立檔案
2. vim xxx.cpp 然後寫代碼就可以了
3. 寫好了以後直接按<F5>,會自動跳回終端編譯並運行,Ctrl-C中斷運行並跳回vim
4. 調試好了以後 <Ctrl-A> 複製代碼到粘貼板,提交
Kuangbin大神的配置:http://www.kuangbin.net/archives/vim-acmicpc
ACM中的vim配置