ACM中的vim配置


把vim当主力编辑器搞acm很长一段时间了,用vim的好处不必多说,

在此总结一下ACM中的vim配置方法,配置直接写到 ~/.vimrc 中就可以了.  



比赛用的14行配置:

syntax on
set cindent
set nu
set tabstop=4
set shiftwidth=4
set background=dark

map <C-A> ggVG"+y
map <F5> :call Run()<CR>
func! Run()
	exec "w"
	exec "!g++ -Wall % -o %<"
	exec "!./%<"
endfunc


日常用的配置  :

主要多了运行java,一键补全头文件,字体什么的

syntax on
set cindent
set mouse=a
set tabstop=4
set shiftwidth=4
set nu
set nocompatible
set showmode
set showcmd
set ignorecase smartcase
set hlsearch
set autoindent
set smarttab
set smartindent

"colorscheme solarized
set background=dark
set gfn=Source\ Code\ Pro\ 14

map <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\ %<"
	endif	
endfunc

map <C-A> ggVG"+y

map <F12> :call SetTitle()<CR>
func SetTitle()
let l = 0
let 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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。