windows7搭建基于VIM的开发环境(3)-VIM基本配置

来源:互联网 发布:斗鱼刷人气软件源代码 编辑:程序博客网 时间:2024/05/17 20:29

windows7搭建基于VIM的开发环境(3)

本系列指导 主要是从无到有完整搭建windows下基于VIM的开发环境,主要分为以下几部分:

  • 搭建msys2下64位编译环境
  • 编译64位且支持python的VIM版本并安装
  • VIM基本配置<本篇>
  • VIM安装vundle
  • VIM安装开发环境所需插件
  • VIM编译安装youcompleteme
  • 开发环境验证

本篇我们主要讲解VIM的基本配置,在上一篇我们已经完成了VIM的安装,本篇的配置主要是修改上篇安装生成的_vrmrc。

一、安装中文vimdoc

从 http://vimcdoc.sourceforge.net/下载最新中文版vimdoc并安装。安装时vim安装目录要选择到D:\Vim\vim80\

二、同步官方exe默认配置

安装完成后默认配置为:

source $VIMRUNTIME/vimrc_example.vimsource $VIMRUNTIME/mswin.vimbehave mswin

增加diff配置,此为官方exe安装版diff配置,默认添加即可,未验证具体功能。修改后为:

"--------------------------------------------------------------------------------" 默认"--------------------------------------------------------------------------------source $VIMRUNTIME/vimrc_example.vimsource $VIMRUNTIME/mswin.vimbehave mswinset 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  if $VIMRUNTIME =~ ' '    if &sh =~ '\<cmd'      if empty(&shellxquote)        let l:shxq_sav = ''        set shellxquote&      endif      let cmd = '"' . $VIMRUNTIME . '\diff"'    else      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'    endif  else    let cmd = $VIMRUNTIME . '\diff'  endif  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3  if exists('l:shxq_sav')    let &shellxquote=l:shxq_sav  endifendfunction

三、增加中文支持

"--------------------------------------------------------------------------------" 配置多语言环境,解决中文乱码问题"--------------------------------------------------------------------------------if has("multi_byte")     " UTF-8 编码     set encoding=utf-8     set termencoding=utf-8     set formatoptions+=mM     set fencs=utf-8,gbk     if v:lang =~? '^/(zh/)/|/(ja/)/|/(ko/)'         set ambiwidth=double     endif     if has("win32")         source $VIMRUNTIME/delmenu.vim         source $VIMRUNTIME/menu.vim         language messages zh_CN.utf-8     endif else     echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte" endif

四、修改编辑配置

"--------------------------------------------------------------------------------" 配置VIM标准显示"--------------------------------------------------------------------------------set nu!colorscheme desert syntax enable syntax on"set lines=35 columns=118 "窗口大小set hlsearch        " 高亮显示搜索结果set incsearch       " 查询时非常方便,如要查找book单词,当输入到/b时,会自动找到autocmd GUIEnter * simalt ~x "窗口最大set cursorcolumnset cursorlineset nobackup"--------------------------------------------------------------------------------" 编程相关的设置"--------------------------------------------------------------------------------"set completeopt=longest,menu    " 关掉智能补全时的预览窗口filetype pluginindenton       " 加了这句才可以用智能补全set showmatch       " 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号set smartindent     " 智能对齐方式set tabstop=4       "tab对应的长度set softtabstop=4   "回退时退回的缩进长度set shiftwidth=4    " 换行时行间交错使用4个空格set expandtab       "缩进用空格表示set noexpandtab     "缩进用制表符表示set autoindent      " 自动对齐set ai!             " 设置自动缩进"自动补全括号inoremap ( ()<ESC>iinoremap [ []<ESC>iinoremap { {}<ESC>iinoremap < <><ESC>i
0 0
原创粉丝点击