VIMRC配置

set fencs=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set langmenu=zh_CN.UTF-8
set ffs=unix,dos,mac
set backspace=indent,eol,start
syntax enable
filetype plugin indent on
set nonu
set ruler
set showmatch
set nocompatible
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set incsearch
set hlsearch
set expandtab
set nobackup
set nowb
set cuc
set cul
set history=1000
set guifont=Ubuntu Mono 11
colorscheme torte

inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=ClosePair('}')<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>

function ClosePair(char)
  if getline('.')[col('.') - 1] == a:char
    return "<Right>"
  else
    return a:char
  endif
endf

function QuoteDelim(char)
  let line = getline('.')
  let col = col('.')
    if line[col - 2] == "\"
      return a:char
    elseif line[col - 1] == a:char
      return "<Right>"
    else
      return a:char.a:char."<Esc>i"
  endif
endf
原文地址:https://www.cnblogs.com/lyuyangly/p/6708036.html