用Vim和MinGW搭建C语言开发平台(Windows)

1.下载Vim 及帮助文档

下载Vim:http://www.vim.org/download.php#pc  选择Windows版本。

下载Vim 中文文档:http://gro.clinux.org/frs/download.php/2071/vimcdoc-1.6.0-setup.exe

2.下载MinGW

下载地址:http://sourceforge.net/project/showfiles.php?group_id=2435 选择MinGW-5.1.3.exe。

3. 安装

首先安装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。

安装Vim及中文文档。

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

"使用中文帮助文档
set helplang=cn

"Set mapleader
let mapleader = ","
let g:mapleader = ","

"显示行号
set nu

"打开语法高亮
syntax on

set softtabstop=4
set shiftwidth=4

"关闭自动备份
set nobackup

"自动缩进设置
set cindent
set smartindent
set incsearch
set autoindent

"Show matching bracets
set showmatch

"Get out of VI's compatible mode
set nocompatible

"Have the mouse enabled all the time
set mouse=a

"Set to auto read when a file is changed from the outside
set autoread

"Enable filetype plugin
filetype plugin on
filetype indent on

"设置配色方案为torte
colo torte

"设置支持的文件编码类项,目前设置为utf-8和gbk两种类型
set fileencodings=utf-8,chinese

"设置搜索结果高亮显示
"set hlsearch

"设置记录的历史操作列表
set history=50

"设置折叠
"set foldcolumn=2
"set foldmethod=indent
"set foldlevel=3

"AutoCommand
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile *.[ch],*.sh,*.java exec ":call SetTitle()"
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G

"设置程序的运行和调试的快捷键F5和Ctrl-F5
map <F5> :call CompileRun()<CR>
map <C-F5> :call Debug()<CR>

"使用<leader>e打开当前文件同目录中的文件
if has("unix")
map ,e :e <C-R>=expand("%:p:h") . "/" <CR>
else
map ,e :e <C-R>=expand("%:p:h") . "/" <CR>
endif

"定义CompileRun函数,用来调用进行编译和运行
func CompileRun()
exec "w"
"C程序
if &filetype == 'c'
exec "!gcc % -g -o %<"
exec "!%<"
endif
endfunc
"结束定义CompileRun

"定义Debug函数,用来调试程序
func Debug()
exec "w"
"C程序
if &filetype == 'c'
exec "!gcc % -g -o %<"
exec "!gdb %<"
endif
endfunc
"结束定义Debug

"定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1, "/#########################################################################")
call append(line("."), "/# Author: WilliamChang")
call append(line(".")+1, "/# Created Time: ".strftime("%c"))
call append(line(".")+2, "/# File Name: ".expand("%"))
call append(line(".")+3, "/# Description: ")
call append(line(".")+4, "/#########################################################################")
call append(line(".")+5, "/#!/bin/bash")
call append(line(".")+6, "")
else
call setline(1, "/*************************************************************************")
call append(line("."), " Author: WilliamChang")
call append(line(".")+1, " Created Time: ".strftime("%c"))
call append(line(".")+2, " File Name: ".expand("%"))
call append(line(".")+3, " Description: ")
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
endif
endfunc

4. 安装完成

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值