我的GVIM配置

参考:GVIM配置

多标签实现: gvim实现多标签

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

" 设定默认解码
set fenc=utf-u

" 设置文件编码, 是UTF-8则用UTF-8解码, 是 gb18030 就用 gb18030解码
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set fileencoding=utf-8 " 新建文件使用的编码

" 解决菜单乱码
set langmenu=zh_CN
let $LANG = 'zh_CN.UTF-8'
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

" 设置显示字体
if has("win32")
    " set guifont=Courier_New:h12
    set guifont=Bitstream_Vera_Sans_Mono:h11:cANSI
    " set guifont=YaHei\ Mono:h11
    "set guifontwide=Microsoft\ Yahei\ Monotype:h11
    "set guifont=YaHei\ Consolas\ Hybrid:h12
endif

" 与windows共享剪贴板
set clipboard+=unnamed

" 主题
" set nu!
colorscheme desert 
" colorscheme elflord
" 语法高亮
syntax enable
syntax on

" 用浅色高亮当前行
if has("gui_running")
    autocmd InsertLeave * se nocul
    autocmd InsertEnter * se cul
endif

" 不要备份文件(根据自己需要取舍)
set nobackup

" 启动的时候不显示那个援助索马里儿童的提示
set shortmess=atI

" 高亮显示匹配的括号
set showmatch

" 命令行补全
set wildmenu
" 自动补全括号,包括大括号
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>

" 自动格式化
set formatoptions=tcrqn

" 继承前一行的缩进方式,特别适用于多行注释
set autoindent


" 为C程序提供自动缩进
set smartindent


" 制表符为4
set tabstop=4

" 统一缩进为4
set softtabstop=4
set shiftwidth=4

" 不要用空格代替制表符
set expandtab

" 在右侧显示窗口
let Tlist_Use_Right_Window = 1

" 打开行号
set number


" F5编译和运行C程序,F6编译和运行C++程序
" 请注意,下述代码在windows下使用会报错
" 需要去掉./这两个字符

" C的编译和运行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
" exec "! ./%<"
exec "! %<"
endfunc



" 不要生成swap文件,当buffer被丢弃的时候隐藏它
setlocal noswapfile
set bufhidden=hide

" 打开时, 有标签
" set showtabline=2


" 文件浏览组件 WinManager
" 用gvim打开代码文件,normal状态下输入命令"wm"
let g:winManagerWindowLayout='FileExplorer|TagList' 
nmap wm :WMToggle<cr>
 


你可能感兴趣的:(我的GVIM配置)