找了好久的gvim配置,终于找到个好用的
原文链接:http://blog.csdn.net/nickwong_/article/details/38228453
普通模式(即命令模式)下,按F5编译运行java,按F9编译运行cpp
1.linux Ubuntu
配置文件位置
- " /home/nick
- "或者
- " /etc/vim/vimrc
- "gui界面点击 edit->startup settings
- "或者
- "gui界面点击 编辑->启动设置
2.windows
配置文件位置
- " 程序安装目录的根目录 如:C:
- \Program Files (x86)\Vim
- "或者
- "gui界面点击 edit->startup
- settings
- "gui界面点击 编辑->启动设置
3. linux Ubuntu
比赛配置文件
- source $VIMRUNTIME/mswin.vim
- behave mswin
- imap <cr> <cr><left><right>
- imap <c-]> {<cr>}<c-o>O<left><right>
- imap <c-d> <c-o>dd
- map <f6> =a{
- map <c-t> :tabnew<cr>
- syn on
- colo darkblue
- set gfn=Courier\ 10\ Pitch\ 12
- set ru nu et sta nowrap ar acd ww=<,>,[,] sw=4 ts=4 cin noswf
- map <f10> :call CR2()<cr><space>
- func CR2()
- exec "update"
- exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%< ; read -n 1\""
- endfunc
- map <f9> :call CR()<cr><space>
- func CR()
- exec "update"
- exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%< < %<.in ; read
- 1\""
- endfunc
- map<f4> :call AddComment()<cr>
- func AddComment()
- if (getline('.')[0] == '/')
- normal ^xx
- else
- normal 0i//
- endif
- endfunc
平时使用配置
- source $VIMRUNTIME/mswin.vim
- behave mswin
- se gfn=Monospace\ 14
- func! RunGpp()
- exec "update"
- if filereadable(expand('%<').'.in')
- exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%< < %<.in ; read -n 1\""
- else
- exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%< ; read -n 1\""
- endif
- endfunc
- func! RunJava()
- exec "update"
- if filereadable(expand('%<').'.in')
- exec "!xterm -fn 10*20 -e \"javac %<.java && time java %< < %<.in ; read -n 1\""
- else
- exec "!xterm -fn 10*20 -e \"javac %<.java && time java %< ; read -n 1\""
- endif
- endfunc
- map <c-t> :tabnew <CR>
- map <c-w> :close <CR>
- map <c-tab> :tabn <CR>
- map <F5> :call RunJava()<CR>
- map <F9> :call RunGpp()<CR>
- imap <F9> <ESC>:call RunGpp()<CR>
- vmap <F9> <ESC>:call RunGpp()<CR>
- colo darkblue
- set tabstop=4
- set softtabstop=4
- set shiftwidth=4
- set cindent
- autocmd! BufWinEnter * lcd %:p:h
- set nu
- if &term=="xterm"
- set t_Co=8
- set t_Sb=^[[4%dm
- set t_Sf=^[[3%dm
- endif
- map<f4> :call AddComment()<cr>
- func AddComment()
- if matchstr(getline('.'), '[^ ]') == '/'
- normal ^xx
- else
- normal ^i//
- endif
- endfunc
- noremap <f6> =a{
- syn on
- map <f2> :call SetTitle()<CR>Gkkk
- func SetTitle()
- let l = 0
- let l = l + 1 | call setline(l, '/*')
- let l = l + 1 | call setline(l, ' * Author: nick wong')
- 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, '#include<cstdio>')
- let l = l + 1 | call setline(l, '#include<iostream>')
- let l = l + 1 | call setline(l, '#include<cstring>')
- let l = l + 1 | call setline(l, '#include<cstdlib>')
- let l = l + 1 | call setline(l, '#include<cmath>')
- 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<map>')
- let l = l + 1 | call setline(l, '#include<set>')
- 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<stack>')
- let l = l + 1 | call setline(l, 'using namespace std;')
- let l = l + 1 | call setline(l, '#define out(x) cout<<#x<<": "<<x<<endl')
- let l = l + 1 | call setline(l, 'const double eps(1e-8);')
- let l = l + 1 | call setline(l, 'const int maxn=10100;')
- let l = l + 1 | call setline(l, 'const long long maxint=-1u>>1;')
- let l = l + 1 | call setline(l, 'const long long maxlong=maxint*maxint;')
- let l = l + 1 | call setline(l, 'typedef long long lint;')
- let l = l + 1 | call setline(l, '')
- let l = l + 1 | call setline(l, 'void init()')
- let l = l + 1 | call setline(l, '{')
- let l = l + 1 | call setline(l, '}')
- let l = l + 1 | call setline(l, '')
- let l = l + 1 | call setline(l, 'void work()')
- let l = l + 1 | call setline(l, '{')
- let l = l + 1 | call setline(l, '}')
- 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, ' ')
- let l = l + 1 | call setline(l, ' init();')
- let l = l + 1 | call setline(l, ' work();')
- let l = l + 1 | call setline(l, ' return 0;')
- let l = l + 1 | call setline(l, '}')
- endfunc
- cd /home/nick/cpp
4.windows
配置文件
- source $VIMRUNTIME/mswin.vim
- behave mswin
- :set shiftwidth=3
- "imap <c-d> <c-o>dd
- imap <cr> <cr><left><right>
- map o o<left><right>
- imap <c-]> {<cr>}<c-o>O<left><right>
- noremap <f6> =a{
- syn on
- colo darkblue
- filetype indent on
- se ru nu ar sw=4 ts=4 noswf et sta nowrap ww=<,>,[,] gfn=Ubuntu\ Mono:h48
- set gfn=courier_new:h16 "设置字体跟字体大小
- autocmd BufEnter * lcd %:p:h
- map <c-t> :tabnew<CR>
- map <c-w> :close<CR>
- map <f9> :call CR()<CR><CR>
- map <c-tab> :tabn<CR>
- map <c-s-tab> :tabp<CR>
- func CR()
- exec 'update'
- if filereadable(expand('%<').'.in')
- exec '!start cmd /c g++ -g -Wall %<.cpp -o %<.exe & pause & %< < %<.in & pause'
- else
- exec '!start cmd /c g++ -Wall %<.cpp -o %<.exe & pause & %< & pause'
- endif
- endfunc
- map <f5> :call CallJava()<CR><CR>
- func CallJava()
- exec 'update'
- if filereadable(expand('%<').'.in')
- exec '!start cmd /c javac %<.java & pause & java %< < %<.in & pause'
- else
- exec '!start cmd /c javac %<.java & pause & java %< & pause'
- endif
- endfunc
- map <f2> :call SetTitle()<CR>Gkkk
- func SetTitle()
- let l = 0
- let l = l + 1 | call setline(l, '/*')
- let l = l + 1 | call setline(l, ' * Author: NICK WONG')
- 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, '#include<iostream>')
- let l = l + 1 | call setline(l, '#include<sstream>')
- let l = l + 1 | call setline(l, '#include<fstream>')
- let l = l + 1 | call setline(l, '#include<vector>')
- let l = l + 1 | call setline(l, '#include<list>')
- let l = l + 1 | call setline(l, '#include<deque>')
- let l = l + 1 | call setline(l, '#include<queue>')
- let l = l + 1 | call setline(l, '#include<stack>')
- let l = l + 1 | call setline(l, '#include<map>')
- let l = l + 1 | call setline(l, '#include<set>')
- let l = l + 1 | call setline(l, '#include<bitset>')
- let l = l + 1 | call setline(l, '#include<algorithm>')
- let l = l + 1 | call setline(l, '#include<cstdio>')
- let l = l + 1 | call setline(l, '#include<cstdlib>')
- let l = l + 1 | call setline(l, '#include<cstring>')
- let l = l + 1 | call setline(l, '#include<cctype>')
- let l = l + 1 | call setline(l, '#include<cmath>')
- let l = l + 1 | call setline(l, '#include<ctime>')
- let l = l + 1 | call setline(l, '#include<iomanip>')
- let l = l + 1 | call setline(l, 'using namespace std;')
- let l = l + 1 | call setline(l, '#define out(x) cout<<#x<<": "<<x<<endl')
- let l = l + 1 | call setline(l, 'const double eps(1e-8);')
- let l = l + 1 | call setline(l, 'const int maxn=10100;')
- let l = l + 1 | call setline(l, 'const long long maxint=-1u>>1;')
- let l = l + 1 | call setline(l, 'const long long maxlong=maxint*maxint;')
- let l = l + 1 | call setline(l, 'typedef long long lint;')
- let l = l + 1 | call setline(l, '')
- let l = l + 1 | call setline(l, 'void init()')
- let l = l + 1 | call setline(l, '{')
- let l = l + 1 | call setline(l, '}')
- let l = l + 1 | call setline(l, '')
- let l = l + 1 | call setline(l, 'void work()')
- let l = l + 1 | call setline(l, '{')
- let l = l + 1 | call setline(l, '}')
- let l = l + 1 | call setline(l, '')
- 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, ' ')
- let l = l + 1 | call setline(l, ' init();')
- let l = l + 1 | call setline(l, ' work();')
- let l = l + 1 | call setline(l, ' return 0;')
- let l = l + 1 | call setline(l, '}')
- endfunc
- map<f4> :call AddComment()<cr>
- func AddComment()
- if matchstr(getline('.'), '[^ ]') == '/'
- normal ^xx
- else
- normal ^i//
- endif
- endfunc
- set printoptions=syntax:n,number:y,portrait:y
- cd E:\cpp "新建文件默认路径
- "set encoding=utf-8
- "set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1 " 如果你要打开的文件编码不在此列,那就添加进去
- "set termencoding=utf-8
5.附上gVim快捷键全图