【转】Gvim配置(Windows and Linux)for C++
转载地址:http://blog.csdn.net/onepiecehuiyu/article/details/8934366
http://mawenhao19930620.blog.163.com/blog/static/12857536120112991818242/
Windows下gvim配置文件_vimrc
首先配置g++到环境变量(配置g++,具体是将devc++的g++.exe的路径比如说:c:/deVC++/bin..加入到环境变量path里面) , 然后将下面的代码复制并保存为_vimrc , 替换掉vim安装文件夹中的_vimrc文件(或者是打开Vim
的启动设定,然后复制下面的代码并保存即可)
"Version: 1.0 by momodi@whuacm
"Modified by ghostboyzone@gmail.com source $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, '')
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 "设置水平滚动条
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 linux
source $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
"colo torte
filetype indent on
set gfn=Courier\ 10\ Pitch\ 12
set 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:h12
autocmd BufEnter * lcd %:p:h
map <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>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, '')
endfunc
map<f4> :call AddComment()<cr>
func AddComment()
if (getline('.')[0] == '/')
normal ^xx
else
normal 0i//
endif
endfunc
set 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
上面的_vimrc配置文件可以根据自己的需求添加和删除相应的内容。
在Windows平台上,是按[F9]编译并执行; 在Linux平台上,是按[F9]或[F10]执行,一个是带输入文件,一个是不带输入文件。
vimrc for windows and linux: 下载地址
【转】Gvim配置(Windows and Linux)for C++的更多相关文章
- Windows下gvim配置
Windows下gvim配置原作地:http://hi.baidu.com/leemoncc/blog/item/a6be15cf40d7ab31b600c806.html 0.准备软件及插件. (a ...
- Windows和Linux环境下Memcached安装与配置(转)
一.memcached安装配置 windows平台安装 1.memcached-1.2.6-win32-bin.zip下载地址: http://code.jellycan.com/memcached/ ...
- JFinal tomcat配置根路径(包括windows和linux)
http://my.oschina.net/u/173975/blog/350666 jfinal的demo直接部署到tomcat上,会由于路径问题导致资源加载不到,路径跳转不正确等问题,解决办法如下 ...
- QWT编译与配置-Windows/Linux环境
QWT编译与配置-Windows/Linux环境 QWT和FFTW两种开源组件是常用的工程软件支持组件,QWT可以提供丰富的绘图组件功能,FFTW是优秀数字波形分析软件.本文使用基于LGPL版权协议的 ...
- Windows 和 Linux 上Redis的安装守护进程配置
# Windows 和 Linux 上Redis的安装守护进程配置 Redis 简介 Redis是目前最常用的非关系型数据库(NOSql)之一,常以Key-Value的形式存储.Redis读写速度 ...
- tomcat配置外部静态资源映射路径(windows和Linux部署)
如果你不想用ngnix配置的话,只单独使用tomcat的话可以看看这篇文章,接下来开始 使用场景 1.单机开发有时侯如果放在war下每次clean都会清理当前项目下静态文件特别折腾. 2.只有启动to ...
- 在Ubuntu14.04下配置Samba 完成linux和windows之间的文件共享
在Windows和Linux之间传递文件可以使用Samba服务.下面是安装步骤: 1. 安装Samba. sudo apt-get install samba 2. 修改配置文件 sudo gedit ...
- gVim 配置方案 采用Vundle管理插件
在Linux下配置vim非常简单,尤其是采用Vundle来管理插件,使得一切用起来得心应手. Maple大神在github上公布了自己的vim配置方案,相当方便好用.详见 https://github ...
- 【转】windows和linux中搭建python集成开发环境IDE
本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...
随机推荐
- 2017多校第10场 HDU 6172 Array Challenge 猜公式,矩阵幂
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6172 题意:如题. 解法: #include <bits/stdc++.h> using ...
- Canvas 高级
一.Canvas 高级 1.变换--位移 translate(x, y) 2.变换-缩放 scale(xS, yS) 3.变换-旋转 rotate(弧度) 4.环境的保存和释放 save() rest ...
- aspxpopupcontrol弹出在aspxpivotgrid的下方
ASPxPopupControl是DevPress控件集中非常优秀的控件之一,适用于弹出式窗口.对话窗口.信息提示窗口等的制作,甚至可用作拖放类的图片容器. 我设计时,想点击ASPxButtonEdi ...
- NFS+inotify实时同步
Inotify简介 Inotify是一种文件系统事件通告机制,能够实时监控文件系统下文件的访问.修改.删除等各种变化情况并将其作为事件通告给用户态应用程序.Linux内核从2.6.13版本后已经集成了 ...
- StringBuilder类的作用,以及与String类的相互转换
# 转载请留言联系 先看一段String类的字符串拼接的代码. String s = "hello" 会在常量池开辟一个内存空间来存储”hello". s += &quo ...
- 【linux】crontab定时命令
参考来源: http://blog.csdn.net/ariessurfer/article/details/7459183 http://www.jb51.net/LINUXjishu/19905. ...
- php上传文件限制
客户端限制(客户端限制在实际上是无法阻止上传): 通过表单隐藏域限制上传文件的最大值 <input type=’hidden’ name=’MAX_FILE_SIZE’ value=’字节数’ ...
- Java Web学习脑图
Java Web学习脑图,从知乎上摘录,感谢知乎网友的分享.
- ofbiz 之minilang解析
编写一个simple method 首先我们需要对输入参数进行验证 ,判断参数是否完整. 1. 验证 1.1. Login-required :这是一个simple-method的属性,对是否需要登陆 ...
- 服务器环境从PHP5升级到PHP7
#安装ppa sudo apt-get install python-software-properties software-properties-common sudo add-apt-repos ...