ACM GVIM配置 在windows/linux 快捷键

找了好久的gvim配置,终于找到个好用的

原文链接:http://blog.csdn.net/nickwong_/article/details/38228453

普通模式(即命令模式)下,按F5编译运行java,按F9编译运行cpp

1.linux Ubuntu

配置文件位置

[plain]  view plain copy
  1. " /home/nick  
  2. "或者  
  3. " /etc/vim/vimrc  
  4. "gui界面点击 edit->startup settings  
  5. "或者  
  6. "gui界面点击 编辑->启动设置  

2.windows

配置文件位置


[plain]  view plain copy
  1. " 程序安装目录的根目录 如:C:  
  2.   
  3. \Program Files (x86)\Vim  
  4. "或者  
  5. "gui界面点击 edit->startup   
  6.   
  7. settings  
  8. "gui界面点击 编辑->启动设置  

3. linux Ubuntu

比赛配置文件

[plain]  view plain copy
  1. source $VIMRUNTIME/mswin.vim  
  2. behave mswin  
  3. imap <cr> <cr><left><right>  
  4. imap <c-]> {<cr>}<c-o>O<left><right>  
  5. imap <c-d> <c-o>dd  
  6. map <f6> =a{  
  7. map <c-t> :tabnew<cr>  
  8. syn on  
  9. colo darkblue  
  10. set gfn=Courier\ 10\ Pitch\ 12  
  11. set ru nu et sta nowrap ar acd ww=<,>,[,] sw=4 ts=4 cin noswf  
  12. map <f10> :call CR2()<cr><space>  
  13. func CR2()  
  14. exec "update"  
  15. exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%< ; read -n 1\""  
  16. endfunc  
  17. map <f9> :call CR()<cr><space>  
  18. func CR()  
  19. exec "update"  
  20. exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%< < %<.in ; read  
  21. 1\""  
  22. endfunc  
  23. map<f4> :call AddComment()<cr>  
  24. func AddComment()  
  25. if (getline('.')[0] == '/')  
  26. normal ^xx  
  27. else  
  28. normal 0i//  
  29. endif  
  30. endfunc  

平时使用配置

[plain]  view plain copy
  1. source $VIMRUNTIME/mswin.vim  
  2. behave mswin  
  3. se gfn=Monospace\ 14  
  4.       
  5. func! RunGpp()    
  6.     exec "update"   
  7.     if filereadable(expand('%<').'.in')  
  8.             exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%< < %<.in ; read -n 1\""   
  9.     else   
  10.             exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%<  ; read -n 1\""   
  11.     endif             
  12. endfunc    
  13.   
  14. func! RunJava()    
  15.     exec "update"   
  16.     if filereadable(expand('%<').'.in')  
  17.             exec "!xterm -fn 10*20 -e \"javac %<.java && time java %<  < %<.in ; read -n 1\""   
  18.     else   
  19.             exec "!xterm -fn 10*20 -e \"javac %<.java && time java %<  ; read -n 1\""   
  20.     endif             
  21. endfunc   
  22.   
  23. map <c-t> :tabnew <CR>  
  24. map <c-w> :close <CR>  
  25. map <c-tab> :tabn <CR>  
  26. map <F5> :call RunJava()<CR>    
  27. map <F9> :call RunGpp()<CR>    
  28. imap <F9> <ESC>:call RunGpp()<CR>  
  29. vmap <F9> <ESC>:call RunGpp()<CR>  
  30.   
  31. colo darkblue  
  32.               
  33. set tabstop=4  
  34. set softtabstop=4  
  35. set shiftwidth=4  
  36. set cindent  
  37. autocmd! BufWinEnter *    lcd %:p:h  
  38. set nu  
  39. if &term=="xterm"  
  40.     set t_Co=8  
  41.     set t_Sb=^[[4%dm  
  42.     set t_Sf=^[[3%dm  
  43. endif  
  44.                   
  45. map<f4> :call AddComment()<cr>  
  46. func AddComment()  
  47.     if matchstr(getline('.'), '[^ ]') == '/'  
  48.         normal ^xx  
  49.     else  
  50.         normal ^i//  
  51.     endif  
  52. endfunc  
  53.   
  54. noremap <f6> =a{  
  55. syn on  
  56.   
  57. map <f2> :call SetTitle()<CR>Gkkk  
  58.     func SetTitle()  
  59.     let l = 0  
  60.     let l = l + 1 | call setline(l, '/*')  
  61.     let l = l + 1 | call setline(l, ' * Author:  nick wong')  
  62.     let l = l + 1 | call setline(l, ' * Created Time:  '.strftime('%c'))  
  63.     let l = l + 1 | call setline(l, ' * File Name: '.expand('%'))  
  64.     let l = l + 1 | call setline(l, ' */')  
  65.     let l = l + 1 | call setline(l, '#include<cstdio>')  
  66.     let l = l + 1 | call setline(l, '#include<iostream>')  
  67.     let l = l + 1 | call setline(l, '#include<cstring>')  
  68.     let l = l + 1 | call setline(l, '#include<cstdlib>')  
  69.     let l = l + 1 | call setline(l, '#include<cmath>')  
  70.     let l = l + 1 | call setline(l, '#include<algorithm>')  
  71.     let l = l + 1 | call setline(l, '#include<string>')  
  72.     let l = l + 1 | call setline(l, '#include<map>')  
  73.     let l = l + 1 | call setline(l, '#include<set>')  
  74.     let l = l + 1 | call setline(l, '#include<vector>')  
  75.     let l = l + 1 | call setline(l, '#include<queue>')  
  76.     let l = l + 1 | call setline(l, '#include<stack>')  
  77.     let l = l + 1 | call setline(l, 'using namespace std;')  
  78.     let l = l + 1 | call setline(l, '#define out(x) cout<<#x<<": "<<x<<endl')  
  79.     let l = l + 1 | call setline(l, 'const double eps(1e-8);')  
  80.     let l = l + 1 | call setline(l, 'const int maxn=10100;')  
  81.     let l = l + 1 | call setline(l, 'const long long maxint=-1u>>1;')  
  82.     let l = l + 1 | call setline(l, 'const long long maxlong=maxint*maxint;')     
  83.     let l = l + 1 | call setline(l, 'typedef long long lint;')  
  84.     let l = l + 1 | call setline(l, '')  
  85.     let l = l + 1 | call setline(l, 'void init()')  
  86.     let l = l + 1 | call setline(l, '{')  
  87.     let l = l + 1 | call setline(l, '}')  
  88.     let l = l + 1 | call setline(l, '')  
  89.     let l = l + 1 | call setline(l, 'void work()')  
  90.     let l = l + 1 | call setline(l, '{')  
  91.     let l = l + 1 | call setline(l, '}')  
  92.     let l = l + 1 | call setline(l, '')  
  93.     let l = l + 1 | call setline(l, 'int main()')  
  94.     let l = l + 1 | call setline(l, '{')  
  95.     let l = l + 1 | call setline(l, '   ')  
  96.     let l = l + 1 | call setline(l, '    init();')  
  97.     let l = l + 1 | call setline(l, '    work();')  
  98.     let l = l + 1 | call setline(l, '    return 0;')  
  99.     let l = l + 1 | call setline(l, '}')  
  100. endfunc  
  101.   
  102. cd /home/nick/cpp  


4.windows

配置文件

[plain]  view plain copy
  1. source $VIMRUNTIME/mswin.vim  
  2. behave mswin  
  3. :set shiftwidth=3    
  4. "imap <c-d> <c-o>dd  
  5. imap <cr> <cr><left><right>  
  6. map o o<left><right>  
  7. imap <c-]> {<cr>}<c-o>O<left><right>  
  8. noremap <f6> =a{  
  9. syn on  
  10. colo darkblue  
  11. filetype indent on  
  12. se ru nu ar sw=4 ts=4 noswf et sta nowrap ww=<,>,[,] gfn=Ubuntu\ Mono:h48  
  13. set gfn=courier_new:h16 "设置字体跟字体大小  
  14. autocmd BufEnter * lcd %:p:h  
  15. map <c-t> :tabnew<CR>  
  16. map <c-w> :close<CR>  
  17. map <f9> :call CR()<CR><CR>  
  18. map <c-tab> :tabn<CR>  
  19. map <c-s-tab> :tabp<CR>  
  20. func CR()  
  21. exec 'update'  
  22. if filereadable(expand('%<').'.in')  
  23.     exec '!start cmd /c g++ -g -Wall %<.cpp -o %<.exe & pause & %< < %<.in & pause'  
  24. else  
  25.     exec '!start cmd /c g++ -Wall %<.cpp -o %<.exe & pause & %< & pause'  
  26. endif  
  27. endfunc  
  28. map <f5> :call CallJava()<CR><CR>  
  29. func CallJava()  
  30. exec 'update'  
  31. if filereadable(expand('%<').'.in')  
  32.     exec '!start cmd /c javac %<.java & pause & java %< < %<.in & pause'  
  33. else  
  34.     exec '!start cmd /c javac %<.java & pause & java %< & pause'  
  35. endif  
  36. endfunc  
  37. map <f2> :call SetTitle()<CR>Gkkk  
  38. func SetTitle()  
  39.     let l = 0  
  40.     let l = l + 1 | call setline(l, '/*')  
  41.     let l = l + 1 | call setline(l, ' * Author: NICK WONG')  
  42.     let l = l + 1 | call setline(l, ' * Created Time:  '.strftime('%c'))  
  43.     let l = l + 1 | call setline(l, ' * File Name: '.expand('%'))  
  44.     let l = l + 1 | call setline(l, ' */')  
  45.     let l = l + 1 | call setline(l, '#include<iostream>')  
  46.     let l = l + 1 | call setline(l, '#include<sstream>')  
  47.     let l = l + 1 | call setline(l, '#include<fstream>')  
  48.     let l = l + 1 | call setline(l, '#include<vector>')  
  49.     let l = l + 1 | call setline(l, '#include<list>')  
  50.     let l = l + 1 | call setline(l, '#include<deque>')  
  51.     let l = l + 1 | call setline(l, '#include<queue>')  
  52.     let l = l + 1 | call setline(l, '#include<stack>')  
  53.     let l = l + 1 | call setline(l, '#include<map>')  
  54.     let l = l + 1 | call setline(l, '#include<set>')  
  55.     let l = l + 1 | call setline(l, '#include<bitset>')  
  56.     let l = l + 1 | call setline(l, '#include<algorithm>')  
  57.     let l = l + 1 | call setline(l, '#include<cstdio>')  
  58.     let l = l + 1 | call setline(l, '#include<cstdlib>')  
  59.     let l = l + 1 | call setline(l, '#include<cstring>')  
  60.     let l = l + 1 | call setline(l, '#include<cctype>')  
  61.     let l = l + 1 | call setline(l, '#include<cmath>')  
  62.     let l = l + 1 | call setline(l, '#include<ctime>')  
  63.     let l = l + 1 | call setline(l, '#include<iomanip>')  
  64.     let l = l + 1 | call setline(l, 'using namespace std;')  
  65.     let l = l + 1 | call setline(l, '#define out(x) cout<<#x<<": "<<x<<endl')  
  66.     let l = l + 1 | call setline(l, 'const double eps(1e-8);')  
  67.     let l = l + 1 | call setline(l, 'const int maxn=10100;')  
  68.     let l = l + 1 | call setline(l, 'const long long maxint=-1u>>1;')  
  69.     let l = l + 1 | call setline(l, 'const long long maxlong=maxint*maxint;')  
  70.     let l = l + 1 | call setline(l, 'typedef long long lint;')  
  71.     let l = l + 1 | call setline(l, '')  
  72.     let l = l + 1 | call setline(l, 'void init()')  
  73.     let l = l + 1 | call setline(l, '{')  
  74.     let l = l + 1 | call setline(l, '}')  
  75.     let l = l + 1 | call setline(l, '')  
  76.     let l = l + 1 | call setline(l, 'void work()')  
  77.     let l = l + 1 | call setline(l, '{')  
  78.     let l = l + 1 | call setline(l, '}')  
  79.     let l = l + 1 | call setline(l, '')  
  80.     let l = l + 1 | call setline(l, '')  
  81.     let l = l + 1 | call setline(l, 'int main()')  
  82.     let l = l + 1 | call setline(l, '{')  
  83.     let l = l + 1 | call setline(l, '   ')  
  84.     let l = l + 1 | call setline(l, '    init();')  
  85.     let l = l + 1 | call setline(l, '    work();')  
  86.     let l = l + 1 | call setline(l, '    return 0;')  
  87.     let l = l + 1 | call setline(l, '}')  
  88. endfunc  
  89.   
  90. map<f4> :call AddComment()<cr>  
  91. func AddComment()  
  92.     if matchstr(getline('.'), '[^ ]') == '/'  
  93.         normal ^xx  
  94.     else  
  95.         normal ^i//  
  96.     endif  
  97. endfunc  
  98.   
  99. set printoptions=syntax:n,number:y,portrait:y  
  100.   
  101. cd E:\cpp "新建文件默认路径  
  102.   
  103. "set encoding=utf-8  
  104. "set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1 " 如果你要打开的文件编码不在此列,那就添加进去  
  105. "set termencoding=utf-8  


5.附上gVim快捷键全图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值