【转】Gvim配置(Windows and Linux)for C++|gvim编译运行c/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
然后将下面代码编译(用你以前的编译器即可,dev-c++,codeblocks都行),找到生成的.exe文件,修改文件名为_run.exe
#include <cstdio>
#include <cstdlib>
#include <ctime>
int main(int argc, char **argv) {
char compiler[] = {};
sprintf(compiler, "g++ %s.cpp -o %s.exe", argv[], argv[]);
char runcommand[] = {};
sprintf(runcommand, "%s.exe", argv[]);
if (system(compiler) == ) {
int t = clock();
if (system(runcommand) == ) {
printf("\nRun Time: %dms\n", clock() - t);
}
}
return ;
}
将_run.exe放到和gvim.exe同一个目录下 。windows下的gvim即配置完毕 。
【转】Gvim配置(Windows and Linux)for C++|gvim编译运行c/c++程序的更多相关文章
- C语言写了一个socket client端,适合windows和linux,用GCC编译运行通过
////////////////////////////////////////////////////////////////////////////////* gcc -Wall -o c1 c1 ...
- C语言写了一个socket server端,适合windows和linux,用GCC编译运行通过
////////////////////////////////////////////////////////////////////////////////* gcc -Wall -o s1 s1 ...
- linux下使用gcc编译运行C/C++程序
编译C 首先,程序编译过程有: 1.预处理(展开宏,头文件,检查代码是否有误) 2.编译(将.c转为汇编代码.s) 3.汇编(将汇编代码.s转为机器代码.o) 4.链接(将所有机器代码.o和库文件链 ...
- 配置 Windows 下的 nodejs C++ 模块编译环境 安装 node-gyp
配置 Windows 下的 nodejs C++ 模块编译环境 根据 node-gyp 指示的 Windows 编译环境说明, 简单一句话就是 "Python + VC++ 编译环境&quo ...
- 在linux下,查看一个运行中的程序, 占用了多少内存
1. 在linux下,查看一个运行中的程序, 占用了多少内存, 一般的命令有 (1). ps aux: 其中 VSZ(或VSS)列 表示,程序占用了多少虚拟内存. RSS列 表示, 程序占用了多少物 ...
- 在Windows命令行中编译运行C/C++程序
此处运行环境是在Windos下,运行cmd命令进入DOS界面 现在有一段简单C++代码(文件名为 demo.cpp),用于计算a*b的值 #include<iostream> using ...
- 在linux中使用cmake编译运行cocos2d-x 3.4 projects
原因: 由于不想在真机环境和 ide中调试环境, 只想在linux端进行 调试和运行, 需要使用cmake对现有的游戏进行编译(cocos2dx-lua 3.4) 修改步骤: 1.修改framewor ...
- sublime text3编译运行C,Java程序的一些配置
环境:linux 64位 桌面环境: gnome Java编译运行 (1)Preferences --> Browse Packages --> 在该文件夹下新建build文件如: Myj ...
- git在windows及linux(源码编译)环境下安装
git在windows下安装 下载地址:https://git-scm.com/ 默认安装即可 验证 git --version git在linux下安装 下载地址:https://mirrors.e ...
随机推荐
- 201521123081《Java程序设计》 第6周学习总结
1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图,对面向对象思想进行一个总结. 注1:关键词与内容不求多,但概念之间的联系要清晰,内容覆盖 ...
- 06jQuery-06-AJAX
1.JS的AJAX AJAX,Asynchronous JavaScript and XML,意思就是用JavaScript执行异步网络请求. 如果要让用户留在当前页面中,同时发出新的HTTP请求,就 ...
- Ansible系列(五):playbook应用和roles自动化批量安装示例
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- 改用Struts2.5 出现404 错误
这个是因为现在Struts 使用 2.5 只需要8 个 jar 包 Xworks-core 已经加到 struts-core中了 原因 是 Jar 包 冲突 导致 的 其次 如果 使用 ...
- Bootstrap笔记合集
一. 为了简化操作,方便使用,Bootstrap通过定义四个类名来控制文本的对齐风格: ☑ .text-left:左对齐 ☑ .text-center:居中对齐 ☑ .text-right ...
- LINUX通过PXE自动部署系统
原理介绍 TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP 协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂.开销不大的 ...
- uvalive 7500 Boxes and Balls
https://vjudge.net/problem/UVALive-7500 题意: 找到规律之后发现给出一个数n,要求找到1 + 2i + ... + x <= n,找出1到x的和. 思路: ...
- Android开发之基于监听的事件处理
在Android 应用开发过程中,常用监听事件如下:(1) ListView事件监听setOn ItemSelectedListener:鼠标滚动时触发setOnItemClickListener: ...
- Paint the Grid Reloaded ZOJ - 3781 图论变形
Paint the Grid Reloaded Time Limit: 2000MS Memory Limit: 65536KB 64bit IO Format: %lld & %ll ...
- poj1067威佐夫博奕
取石子游戏 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 31490 Accepted: 10374 Descripti ...