Windows:

首先安装Vim , MinGW,假设安装目录为D:\MinGW。

配置环境变量:

LIBRARY_PATH=D:\MinGW\lib

C_INCLUDE_PATH=D:\MinGW\include

CPLUS_INCLUDE_PATH=D:\MinGW\include\c++\3.2.3;d:\MinGW\include\c++\3.2.3\mingw32;D:\MinGW\include\c++\3.2.3\backward;D:\MinGW\include

把D:\MinGW\bin;添加到Path变量最前端。

测试MimGW安装是否成功:在命令行输入gcc -v。

Ubuntu:

直接执行命令3不可行情况下按顺序执行即可解决

1.sudo vim /etc/apt/sources.list

//在sources.list末尾添加,保存

deb http://us.archive.ubuntu.com/ubuntu trusty main universe

2.sudo apt-get update

3.sudo apt-get install mingw32

安装常用的编译包

1.sudo apt-get install dpkg-dev

2.sudo apt-get install build-essential

3.sudo apt-get install g++-4.4

安装Vim及中文文档。

修改Vim配置文件,用记事本打开Vim安装目录下的_vimrc文件,粘帖如下内容(可按照个人爱好配置):

unbutu vim 配置文件路径 /etc/vim/vimrc

set sw=
set ts=
set cin
set si
set nu cd E:\ACM\code
color pablo set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction "------------------------------------------------------------------------------
" < 判断操作系统是否是 Windows 还是 Linux >
"------------------------------------------------------------------------------
if(has("win32") || has("win64") || has("win95") || has("win16"))
let g:iswindows =
else
let g:iswindows =
endif "------------------------------------------------------------------------------
" < 判断是终端还是 Gvim >
"------------------------------------------------------------------------------
if has("gui_running")
let g:isGUI =
else
let g:isGUI =
endif "------------------------------------------------------------------------------
" < 编译、连接、运行配置 >
"------------------------------------------------------------------------------
" F9 一键保存、编译、连接存并运行
map <F9> :call Run()<CR>
imap <F9> <ESC>:call Run()<CR> " Ctrl + F9 一键保存并编译
map 蝔 :call Compile()<CR>
imap 蝔 <ESC>:call Compile()<CR> " Ctrl + F10 一键保存并连接
map <c-F10> :call Link()<CR>
imap <c-F10> <ESC>:call Link()<CR> map <F7> <ESC>^i//<ESC>
map <F8> <ESC>^df/<ESC>
map <F6> <ESC>ggVG"+y<ESC>
map 蝐 <ESC>"+p<ESC>
if has('gui_running') && has("win32")
map <F11> :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", )<CR>
endif let s:LastShellReturn_C =
let s:LastShellReturn_L =
let s:ShowWarning =
let s:Obj_Extension = '.o'
let s:Exe_Extension = '.exe'
let s:Sou_Error = let s:windows_CFlags = 'gcc\ -std=gnu++0x\ -fexec-charset=gbk\ -Wall\ -g\ -O3\ -c\ %\ -o\ %<.o'
let s:linux_CFlags = 'gcc\ -std=gnu++0x\ -Wall\ -g\ -O3\ -c\ %\ -o\ %<.o' let s:windows_CPPFlags = 'g++\ -std=gnu++0x\ -fexec-charset=gbk\ -Wall\ -g\ -O3\ -c\ %\ -o\ %<.o'
let s:linux_CPPFlags = 'g++\ -std=gnu++0x\ -Wall\ -g\ -O3\ -c\ %\ -o\ %<.o' func! Compile()
exe ":ccl"
exe ":update"
if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx"
let s:Sou_Error =
let s:LastShellReturn_C =
let Sou = expand("%:p")
let Obj = expand("%:p:r").s:Obj_Extension
let Obj_Name = expand("%:p:t:r").s:Obj_Extension
let v:statusmsg = ''
if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou)))
redraw!
if expand("%:e") == "c"
if g:iswindows
exe ":setlocal makeprg=".s:windows_CFlags
else
exe ":setlocal makeprg=".s:linux_CFlags
endif
echohl WarningMsg | echo " compiling..."
silent make
elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
if g:iswindows
exe ":setlocal makeprg=".s:windows_CPPFlags
else
exe ":setlocal makeprg=".s:linux_CPPFlags
endif
echohl WarningMsg | echo " compiling..."
silent make
endif
redraw!
if v:shell_error !=
let s:LastShellReturn_C = v:shell_error
endif
if g:iswindows
if s:LastShellReturn_C !=
exe ":bo cope"
echohl WarningMsg | echo " compilation failed"
else
if s:ShowWarning
exe ":bo cw"
endif
echohl WarningMsg | echo " compilation successful"
endif
else
if empty(v:statusmsg)
echohl WarningMsg | echo " compilation successful"
else
exe ":bo cope"
endif
endif
else
echohl WarningMsg | echo ""Obj_Name"is up to date"
endif
else
let s:Sou_Error =
echohl WarningMsg | echo " please choose the correct source file"
endif
exe ":setlocal makeprg=make"
endfunc func! Link()
call Compile()
if s:Sou_Error || s:LastShellReturn_C !=
return
endif
let s:LastShellReturn_L =
let Sou = expand("%:p")
let Obj = expand("%:p:r").s:Obj_Extension
if g:iswindows
let Exe = expand("%:p:r").s:Exe_Extension
let Exe_Name = expand("%:p:t:r").s:Exe_Extension
else
let Exe = expand("%:p:r")
let Exe_Name = expand("%:p:t:r")
endif
let v:statusmsg = ''
if filereadable(Obj) && (getftime(Obj) >= getftime(Sou))
redraw!
if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj))
if expand("%:e") == "c"
setlocal makeprg=gcc\ -o\ %<\ %<.o
echohl WarningMsg | echo " linking..."
silent make
elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
setlocal makeprg=g++\ -o\ %<\ %<.o
echohl WarningMsg | echo " linking..."
silent make
endif
redraw!
if v:shell_error !=
let s:LastShellReturn_L = v:shell_error
endif
if g:iswindows
if s:LastShellReturn_L !=
exe ":bo cope"
echohl WarningMsg | echo " linking failed"
else
if s:ShowWarning
exe ":bo cw"
endif
echohl WarningMsg | echo " linking successful"
endif
else
if empty(v:statusmsg)
echohl WarningMsg | echo " linking successful"
else
exe ":bo cope"
endif
endif
else
echohl WarningMsg | echo ""Exe_Name"is up to date"
endif
endif
setlocal makeprg=make
endfunc func! Run()
let s:ShowWarning =
call Link()
let s:ShowWarning =
if s:Sou_Error || s:LastShellReturn_C != || s:LastShellReturn_L !=
return
endif
let Sou = expand("%:p")
let Obj = expand("%:p:r").s:Obj_Extension
if g:iswindows
let Exe = expand("%:p:r").s:Exe_Extension
else
let Exe = expand("%:p:r")
endif
if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou)
redraw!
echohl WarningMsg | echo " running..."
if g:iswindows
exe ":!%<.exe"
else
if g:isGUI
exe ":!gnome-terminal -e ./%<"
else
exe ":!./%<"
endif
endif
redraw!
echohl WarningMsg | echo " running finish"
endif
endfunc

Window/Linux + Vim + MingW 配置的更多相关文章

  1. Linux - vim安装 配置与使用

    一 Vim 简单介绍 曾经一直用vi,近期開始使用 vim,以下将两者做一下比較. vi和vim都是word=%E5%A4%9A%E6%A8%A1&fr=qb_search_exp&i ...

  2. Linux vim 入门 配置 及 使用初步

    网上能够找到的,关于VI的教程,更是多为能吓死人的上百页说明.事实上, 从我个人的实践看,全然不须要如此夸张.要完毕最主要的编辑.仅仅要熟悉几个命令,就是把VIM用得非常好. 这里就列举一下: Esc ...

  3. windows下LINUX模拟终端Cypwin以及Vim的配置使用

    Cypwin的安装 从官网下载相应版本后,直接安装. 官网地址:Cypwin 安装过程中可以选择相应的Packages,我们需要安装的Vim就需要在这一步中选择相应的包. Cypwin的使用 纯命令行 ...

  4. linux环境下Vim的配置

    原文链接:http://blog.chinaunix.net/uid-26826958-id-3272375.html  (本文转自此链接中的部分内容,但做了适当修改) 安装vim命令:sudo ap ...

  5. Linux网络属性配置

    目录 IP地址分类 如何将Linux主机接入到网络中 网络接口的命名方式 ifcfg系列命令 如何配置主机名 如何配置DNS服务器指向 iproute2系列命令 Linux管理网络服务 永久生效配置路 ...

  6. Linux网络属性配置命令和管理详解

    一.Linux网络属性配置 1.Linux主机接入到网络方式 IP/NETMASK:实现本地网络通信 路由(网关):可以进行跨网络通信 DNS服务器地址:基于主机名的通信,Linux可以有三个DNS地 ...

  7. Linux下安装配置Jmeter5.1,并执行jmx文件

    Windows下的jmeter是GUI模式,可查看操作,但是GUI对性能的干扰比较大,所有一般压测会在Linux上运行. 下面是Linux下安装配置Jmeter5.1,并执行jmx文件的步骤, 一.安 ...

  8. redis的Linux系统安装与配置、redis的api使用、高级用法之慢查询、pipline事物

    今日内容概要 redis 的linux安装和配置 redis 的api使用 高级用法之慢查询 pipline事务 内容详细 1.redis 的linux安装和配置 # redis 版本选择问题 -最新 ...

  9. 在Linux虚拟机下配置tomcat

    1.到Apache官网下载tomcat http://tomcat.apache.org/download-80.cgi 博主我下载的是tomcat8 博主的jdk是1.8 如果你们的jdk是1.7或 ...

随机推荐

  1. leetcode.分治.241为运算表达式设计优先级-Java

    1. 具体题目 给定一个含有数字和运算符的字符串,为表达式添加括号,改变其运算优先级以求出不同的结果.你需要给出所有可能的组合的结果.有效的运算符号包含 +, - 以及 * . 示例 1: 输入: & ...

  2. Codefores 507D The Maths Lecture( 数位DP )

    D. The Maths Lecture time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. 【目录】linux 编程

    随笔分类 - linux 编程 Linux编程 24 shell编程(结构化 if [ condition ] 数值比较,字符串比较) 摘要: 一.概述 接着上篇讲的结构化命令,最后讲到了test命令 ...

  4. 【学习总结】Python-3-身份运算符 is 与 == 区别

    参考:菜鸟教程-Python3运算符 身份运算符 is 和 is not:用于比较两个对象的存储单元 判断两个标识符是不是引用自相同或不同对象,返回一个布尔值 对于"同一个对象"中 ...

  5. CentOS使用手册(二)

    前言: 本篇目录: 1.Linux软件安装调试 2.Linux内存.CPU.进程.端口.硬盘管理 3.Linux systemctl管理服务.防火墙firewalld以及SELinux配置 Linux ...

  6. 关于 ioctl 函数

    ioctl函数是用于控制的设备的接口 1.底层: long (*unlocked_ioctl) (struct file *filp, unsigned int cmd, unsigned long ...

  7. 常用yum源之(Percona MySQL)

    [percona]name = CentOS $releasever - Perconabaseurl=http://repo.percona.com/centos/$releasever/os/$b ...

  8. 内嵌iframe撑高父容器,底部有4px留白问题解决办法

    由于iframe是特殊标签, 1,iframe默认是块元素,其display样式默认值是block2,frame应该说即不是块元素也不是行内元素,它虽然有display样式,但其默认值是none3,f ...

  9. Guarded Suspension模式简单实现

    Guarded Suspension 意为保护暂停,假设服务器很短时间内承受大量的客户端请求,客户端请求的数量超过服务器本身的即时处理能力,而服务器又不能丢弃任何一个客户端请求,此时可以让客户端的请求 ...

  10. OS---磁盘存储器

    1.概述 1.1 磁盘存储器  不仅  容量大.存取速度快  而且  可以随机存取: 现代计算机都配置了  磁盘存储器,以  它  为主  存放文件: 对文件 的操作,都将涉及对磁盘的访问: 1.2 ...