Gvim配置(Windows and Linux)for C++
2012-06-04 08:17
411 查看
Windows下gvim配置文件_vimrc(页面底部附下载地址)
首先配置g++到环境变量 , 然后将下面的代码复制并保存为_vimrc , 替换掉vim安装文件夹中的_vimrc文件(或者是打开Vim
的启动设定,然后复制下面的代码并保存即可)
---------------------------------------------------------------------------------------------------------------
然后将下面代码编译, 修改产生的exe文件名为_run.exe
将_run.exe放到和gvim.exe同一个目录下 。windows下的gvim即配置完毕 。
Linux下gvim配置文件_vimrc
打开Vim的启动设定,然后复制下面的代码并保存即可
上面的_vimrc配置文件可以根据自己的需求添加和删除相应的内容。
vimrc for windows and linux: 下载地址
首先配置g++到环境变量 , 然后将下面的代码复制并保存为_vimrc , 替换掉vim安装文件夹中的_vimrc文件(或者是打开Vim
的启动设定,然后复制下面的代码并保存即可)
"Version: 1.0 by momodi@whuacm "Modified by ghostboyzone@gmail.comsource $VIMRUNTIME/mswin.vim behave mswin 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 desert filetype indent on se ru nu ar sw=4 ts=4 noswf et sta nowrap ww=<,>,[,] gfn=Consolas:h12 autocmd BufEnter * lcd %:p:h map <c-t> :tabnew<CR> map <f9> :call CR()<CR><CR> func CR() exec 'update' if filereadable(expand('%<').'.in') exec '!start cmd /c _run %< < %<.in & pause' else exec '!start cmd /c _run %< & 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: mybestwishes') 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 <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 <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 <vector>') let l = l + 1 | call setline(l, '#include <stack>') 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 <time.h>') let l = l + 1 | call setline(l, 'using namespace std;') let l = l + 1 | call setline(l, 'const int maxint = -1u>>1;') let l = l + 1 | call setline(l, '') let l = l + 1 | call setline(l, 'int main() {') let l = l + 1 | call setline(l, ' return 0;') let l = l + 1 | call setline(l, '}') let l = l + 1 | call setline(l, '') endfuncmap<f4> :call AddComment()<cr> func AddComment() if matchstr(getline('.'), '[^ ]') == '/' normal ^xx else normal ^i// endif endfuncset printoptions=syntax:n,number:y,portrait:y "设置水平滚动条 set guioptions+=b"set encoding=utf-8 "set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1 " 如果你要打开的文件编码不在此列,那就添加进去 "set termencoding=utf-8
---------------------------------------------------------------------------------------------------------------
然后将下面代码编译, 修改产生的exe文件名为_run.exe
#include <cstdio>#include <cstdlib>#include <ctime> int main(int argc, char **argv) { char compiler[50] = {}; sprintf(compiler, "g++ %s.cpp -o %s.exe", argv[1], argv[1]); char runcommand[50] = {}; sprintf(runcommand, "%s.exe", argv[1]); if (system(compiler) == 0) { int t = clock(); if (system(runcommand) == 0) { printf("\nRun Time: %dms\n", clock() - t); } } return 0;}
将_run.exe放到和gvim.exe同一个目录下 。windows下的gvim即配置完毕 。
Linux下gvim配置文件_vimrc
打开Vim的启动设定,然后复制下面的代码并保存即可
"Vim for linuxsource $VIMRUNTIME/mswin.vimbehave mswinimap <c-d> <c-o>ddimap <cr> <cr><left><right>map o o<left><right>imap <c-]> {<cr>}<c-o>O<left><right>noremap <f6> =a{syn oncolo desert"colo tortefiletype indent on set gfn=Courier\ 10\ Pitch\ 12set ru nu et sta nowrap ar acd ww=<,>,[,] sw=4 ts=4 cin noswf "se ru nu ar sw=4 ts=4 noswf et sta nowrap ww=<,>,[,] gfn=Consolas:h12autocmd BufEnter * lcd %:p:hmap <c-t> :tabnew<CR> map <f9> :call CR()<CR><CR>func CR()exec "update"exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -o %< && time ./%< < %<.in ; read -n 1\""endfunc 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 <f2> :call SetTitle()<CR>Gkkkfunc SetTitle()let l = 0let l = l + 1 | call setline(l, '/*')let l = l + 1 | call setline(l, ' * Author: mybestwishes')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 <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 <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 <vector>')let l = l + 1 | call setline(l, '#include <stack>')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 <time.h>')let l = l + 1 | call setline(l, 'using namespace std;')let l = l + 1 | call setline(l, 'const int maxint = -1u>>1;')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, 'int main() {')let l = l + 1 | call setline(l, ' return 0;')let l = l + 1 | call setline(l, '}')let l = l + 1 | call setline(l, '')endfunc map<f4> :call AddComment()<cr>func AddComment() if (getline('.')[0] == '/') normal ^xx else normal 0i// endifendfuncset printoptions=syntax:n,number:y,portrait:yset guioptions+=b set encoding=utf-8set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1 set termencoding=utf-8
上面的_vimrc配置文件可以根据自己的需求添加和删除相应的内容。
vimrc for windows and linux: 下载地址
相关文章推荐
- Gvim配置(Windows and Linux)for C++
- 【转】Gvim配置(Windows and Linux)for C++
- Gvim配置(Windows and Linux)for C/C++
- 【转】Gvim配置(Windows and Linux)for C++|gvim编译运行c/c++程序
- Gvim配置(Windows and Linux)for C/C++
- ubuntu下gvim配置文件for C/C++
- 俺的gVim配置文件(解决了菜单栏,右键菜单和提示框中文乱码问题)(for windows,linux下应该也没问题)
- 在windows下使用 Visual Leak Detector for Visual C++ 2008的安装和配置
- Kinect for Windows SDK C++ 开发 Visual Studio 2010环境配置
- Windows下配置Eclipse for C++
- 在windows下使用 Visual Leak Detector for Visual C++ 2008的安装和配置
- Gvim配置for C/C++
- gvim配置文件for C/C++
- Windows下配置Eclipse for C++
- ubuntu下gvim配置文件for C/C++
- Windows下配置Eclipse for C++
- 在windows下使用 Visual Leak Detector for Visual C++ 2008的安装和配置
- Gvim for Windows的DIY配置过程
- Gvim C++ IDE for windows XP (Ubuntu)
- gvim for windows的剪贴板操作