GVIM和VIM的配置

我觉得挺好用的一个配置 按F9即可编译并运行而且还有运行时间



转载于: http://mawenhao19930620.blog.163.com/blog/static/12857536120112991818242/


Windows下gvim配置文件_vimrc(页面底部附下载地址

首先配置g++到环境变量 , 然后将下面的代码复制并保存为_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=Courier10Pitch12

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 -%< && time ./%< < %<.in ; read -1\""

endfunc

map <f10> :call CR2()<cr><space>

func CR2()

exec "update"

exec "!xterm -fn 10*20 -e \"g++ %<.cpp -Wall -%< && time ./%< ; read -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配置文件可以根据自己的需求添加和删除相应的内容。

vimrc for windows and linux: 下载地址



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
gvimVim编辑器的图形界面版本,可以像其它图形界面的文本编辑器一样使用鼠标操作。下面是gvim的最全配置和插件: ## 基本配置 ```vim set encoding=utf-8 " 设置编码为UTF-8 set fileencodings=utf-8,gb2312,gbk,gb18030,big5 " 设置文件编码 set fileformats=unix,dos,mac " 设置文件格式 set tabstop=4 " 设置制表符宽度为4个空格 set shiftwidth=4 " 设置缩进宽度为4个空格 set expandtab " 将制表符自动转换为空格 set smartindent " 智能缩进 set number " 显示行号 set cursorline " 高亮当前行 set hlsearch " 高亮搜索结果 set incsearch " 实时搜索 set showmatch " 高亮匹配的括号 set noswapfile " 不生成交换文件 set backup " 生成备份文件 set undofile " 生成撤销文件 set autochdir " 自动切换工作目录 ``` ## 插件管理 可以使用Vim插件管理工具Vundle或者Pathogen进行插件管理,这里以Vundle为例: ```vim " 安装Vundle插件管理器 if !filereadable(expand('~/.vim/bundle/Vundle.vim/autoload.vim')) echo "Installing Vundle" silent !mkdir -p ~/.vim/bundle silent !git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim endif " 设置插件目录 set rtp+=~/.vim/bundle/Vundle.vim " 插件列表 call vundle#begin() Plugin 'VundleVim/Vundle.vim' Plugin 'tpope/vim-fugitive' Plugin 'scrooloose/nerdtree' Plugin 'altercation/vim-colors-solarized' Plugin 'ctrlpvim/ctrlp.vim' Plugin 'jiangmiao/auto-pairs' call vundle#end() ``` ## 插件列表 以下是gvim常用的插件列表: 1. [Vundle](https://github.com/VundleVim/Vundle.vim):插件管理器 2. [vim-fugitive](https://github.com/tpope/vim-fugitive):Git插件 3. [nerdtree](https://github.com/scrooloose/nerdtree):文件浏览器插件 4. [vim-colors-solarized](https://github.com/altercation/vim-colors-solarized):主题插件 5. [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim):快速文件搜索插件 6. [auto-pairs](https://github.com/jiangmiao/auto-pairs):自动补全括号插件 以上是gvim最全的配置和插件,你可以根据自己的需求进行配置

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值